user12893: Is there a quick way to do transactions knowing only the private key(secret exponent) and the destination address, preferably from a command line utility such as pycoin?
I am using Debian/Ubuntu and python 2.7.

user9382: For Ubuntu, Python 2.7 (same setup as me) I'd highly recommend either:

pybitcointools (install using pip install pybitcointools for version 1.1.15 or pip install bitcoin for version 1.1.25 (recommended)
sx/libbitcoin. Might need to install using mastercoin's install.sh script, depending on whether dependencies work (I had issues using Tasty Tahr Ubuntu 14.04).

Both are CLIs, and both work similarly allowing piping of variables, etc. However pybitcointools seems to support the address history function (API call to Blockchain.info/Blockr.io) and the support documentation for pybitcointools seems to be more self-explanatory than the brief sx tutorial.

user9382: Using SX tools.
At bash command line, create a WIF private key file called private.key for 1MBngSqZbMydscpzSoehjP8kznMaHAzh9y with this data inside:  5HvofFG7K1e2aeWESm5pbCzRHtCSiZNbfLYXBvxyA57DhKHV4U3. FYI, the private key (as discussed here) is a brainwallet of mrbubbymrbubbymrbubby! (which is cool, because 1MB ≈ brainwallet phrase)
OK, now we run these aliases/commands in the exact order given (node comments explaining each step):

DECODED_ADDR=$(cat private.key | sx addr | sx decode-addr) # hash160
PREVOUT_SCRIPT=$(sx rawscript dup hash160 [ $DECODED_ADDR ] equalverify checksig)  # hash160 + script padding
SIGNATURE=$(cat private.key | sx sign-input txfile.tx 0 $PREVOUT_SCRIPT)   # 72 digit der signature
SIGNATURE_AND_PUBKEY_SCRIPT=$(sx rawscript [ $SIGNATURE ] [ $(cat private.key | sx pubkey) ])  # 278 digit script/sig/pubkey
sx set-input txfile.tx 0 $SIGNATURE_AND_PUBKEY_SCRIPT > txfile.tx.signed    # 192 digit signed txn

In this instance, the aliases give the following:

DECODED_ADDR=dd6cce9f255a8cc17bda8ba0373df8e861cb866e
PREVOUT_SCRIPT=76a914dd6cce9f255a8cc17bda8ba0373df8e861cb866e88ac
SIGNATURE=3045022100da43201760bda697222002f56266bf65023fef2094519e13077f777baed553b102205ce35d05eabda58cd50a67977a65706347cc25ef43153e309ff210a134722e9e01
SIGNATURE_AND_PUBKEY_SCRIPT=483045022100da43201760bda697222002f56266bf65023fef2094519e13077f777baed553b102205ce35d05eabda58cd50a67977a65706347cc25ef43153e309ff210a134722e9e0141042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9

FINAL SIGNED TXN:
Here's the final raw Txn which sends BTC to 14zWNsgUMmHhYx4suzc2tZD6HieGbkQi5s.
0100000001be66e10da854e7aea9338c1f91cd489768d1d6d7189f586d7a3613f2a24d5396000000008b483045022100da43201760bda697222002f56266bf65023fef2094519e13077f777baed553b102205ce35d05eabda58cd50a67977a65706347cc25ef43153e309ff210a134722e9e0141042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9ffffffff0123ce0100000000001976a9142bc89c2702e0e618db7d59eb5ce2f0f147b4075488ac00000000
File Contents:
private.key = 5HvofFG7K1e2aeWESm5pbCzRHtCSiZNbfLYXBvxyA57DhKHV4U3
txfile.tx = 0100000001be66e10da854e7aea9338c1f91cd489768d1d6d7189f586d7a3613f2a24d53960000000000ffffffff0123ce0100000000001976a9142bc89c2702e0e618db7d59eb5ce2f0f147b4075488ac00000000
rawscript.sigpubkey.tx = 473044022054f60e8ae19411541597167362d12fc132e081a546c766bfd69c16d9d58e268a022048055c7fd8bf78e48543e8756bb3b26336df35b812a184119ba0e9d525bbb8aa0141042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9
signed.tx = 0100000001be66e10da854e7aea9338c1f91cd489768d1d6d7189f586d7a3613f2a24d5396000000000b00000c0000000000000000ffffffff0123ce0100000000001976a9142bc89c2702e0e618db7d59eb5ce2f0f147b4075488ac00000000

user23123: In order to create a transaction, you need the blockchain, or at least the transactions in the blockchain that belong to a particular address (technical term would be unspent transaction outputs or UTXOs for a particular script). There are three ways this can happen:

You have a local bitcoind or btcd installed which would let you query for transactions, at the expense of downloading the entire blockchain.
You use an electrum or some other SPV server to query for transactions, at the expense of connecting to these nodes.
You use a centralized service such as blockchain.info to gather all transactions at the expense of having to trust the centralized service to be up all the time and to not be corrupt.

Any way you slice it, you cannot get the transaction data from a python library that doesn't connect to some other service. Hence tools like pybitcointools or pycoin will not get you what you need. sx has some tools to look up utxos using method #3.
You can install Armory or bitcoind and import the private key and use method #1 above or use something like pi-wallet and use method #2.

12893: <p>Is there a quick way to do transactions knowing only the private key(secret exponent) and the destination address, preferably from a command line utility such as pycoin?</p>

<p>I am using Debian/Ubuntu and python 2.7.</p>
 9382: <p>For Ubuntu, Python 2.7 (same setup as me) I'd highly recommend either:</p>

<ol>
<li><a href="http://www.github.com/vbuterin/pybitcointools/" rel="nofollow">pybitcointools</a> (install using <em>pip install pybitcointools</em> for version 1.1.15 or <em>pip install bitcoin</em> for version 1.1.25 (recommended)</li>
<li><a href="http://sx.dyne.org" rel="nofollow">sx</a>/libbitcoin. <a href="https://bitcoin.stackexchange.com/questions/32219/ubuntu-14-lts-with-sx-tools-installation-issues/32411#32411">Might need to install using mastercoin's <em>install.sh</em> script</a>, depending on whether dependencies work (I had issues using Tasty Tahr Ubuntu 14.04).</li>
</ol>

<p>Both are CLIs, and both work similarly allowing piping of variables, etc. However <em>pybitcointools</em> seems to support the <em>address history</em> function (API call to Blockchain.info/Blockr.io) and the <a href="https://github.com/vbuterin/pybitcointools/blob/master/README.txt" rel="nofollow">support documentation for <em>pybitcointools</em></a> seems to be more self-explanatory than the brief <em>sx</em> tutorial.</p>
 9382: <p>Using SX tools.</p>

<p>At bash command line, create a WIF private key file called <code>private.key</code> for 1MBngSqZbMydscpzSoehjP8kznMaHAzh9y with this data inside:  <code>5HvofFG7K1e2aeWESm5pbCzRHtCSiZNbfLYXBvxyA57DhKHV4U3</code>. FYI, the private key (as discussed <a href="https://bitcoin.stackexchange.com/questions/32628/redeeming-a-raw-transaction-step-by-step-example-required/32695#32695">here</a>) is a brainwallet of <em>mrbubbymrbubbymrbubby!</em> (which is cool, because 1MB ≈ brainwallet phrase)</p>

<p>OK, now we run these aliases/commands in the exact order given (node comments explaining each step):</p>

<ol>
<li><code>DECODED_ADDR=$(cat private.key | sx addr | sx decode-addr) # hash160</code></li>
<li><code>PREVOUT_SCRIPT=$(sx rawscript dup hash160 [ $DECODED_ADDR ] equalverify checksig)  # hash160 + script padding</code></li>
<li><code>SIGNATURE=$(cat private.key | sx sign-input txfile.tx 0 $PREVOUT_SCRIPT)   # 72 digit der signature</code></li>
<li><code>SIGNATURE_AND_PUBKEY_SCRIPT=$(sx rawscript [ $SIGNATURE ] [ $(cat private.key | sx pubkey) ])  # 278 digit script/sig/pubkey</code></li>
<li><code>sx set-input txfile.tx 0 $SIGNATURE_AND_PUBKEY_SCRIPT &gt; txfile.tx.signed    # 192 digit signed txn</code></li>
</ol>

<p>In this instance, the aliases give the following:</p>

<ul>
<li><code>DECODED_ADDR=dd6cce9f255a8cc17bda8ba0373df8e861cb866e</code></li>
<li><code>PREVOUT_SCRIPT=76a914dd6cce9f255a8cc17bda8ba0373df8e861cb866e88ac</code></li>
<li><code>SIGNATURE=3045022100da43201760bda697222002f56266bf65023fef2094519e13077f777baed553b102205ce35d05eabda58cd50a67977a65706347cc25ef43153e309ff210a134722e9e01</code></li>
<li><code>SIGNATURE_AND_PUBKEY_SCRIPT=483045022100da43201760bda697222002f56266bf65023fef2094519e13077f777baed553b102205ce35d05eabda58cd50a67977a65706347cc25ef43153e309ff210a134722e9e0141042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9</code></li>
</ul>

<p><strong>FINAL SIGNED TXN:</strong></p>

<p>Here's the final raw Txn which sends BTC to 14zWNsgUMmHhYx4suzc2tZD6HieGbkQi5s.</p>

<p><code>0100000001be66e10da854e7aea9338c1f91cd489768d1d6d7189f586d7a3613f2a24d5396000000008b483045022100da43201760bda697222002f56266bf65023fef2094519e13077f777baed553b102205ce35d05eabda58cd50a67977a65706347cc25ef43153e309ff210a134722e9e0141042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9ffffffff0123ce0100000000001976a9142bc89c2702e0e618db7d59eb5ce2f0f147b4075488ac00000000</code></p>

<p>File Contents:</p>

<p>private.key = <code>5HvofFG7K1e2aeWESm5pbCzRHtCSiZNbfLYXBvxyA57DhKHV4U3</code>
txfile.tx = <code>0100000001be66e10da854e7aea9338c1f91cd489768d1d6d7189f586d7a3613f2a24d53960000000000ffffffff0123ce0100000000001976a9142bc89c2702e0e618db7d59eb5ce2f0f147b4075488ac00000000</code>
rawscript.sigpubkey.tx = <code>473044022054f60e8ae19411541597167362d12fc132e081a546c766bfd69c16d9d58e268a022048055c7fd8bf78e48543e8756bb3b26336df35b812a184119ba0e9d525bbb8aa0141042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9</code>
signed.tx = <code>0100000001be66e10da854e7aea9338c1f91cd489768d1d6d7189f586d7a3613f2a24d5396000000000b00000c0000000000000000ffffffff0123ce0100000000001976a9142bc89c2702e0e618db7d59eb5ce2f0f147b4075488ac00000000</code></p>
 23123: <p>In order to create a transaction, you need the blockchain, or at least the transactions in the blockchain that belong to a particular address (technical term would be unspent transaction outputs or UTXOs for a particular script). There are three ways this can happen:</p>

<ol>
<li><p>You have a local bitcoind or btcd installed which would let you query for transactions, at the expense of downloading the entire blockchain.</p></li>
<li><p>You use an electrum or some other SPV server to query for transactions, at the expense of connecting to these nodes.</p></li>
<li><p>You use a centralized service such as blockchain.info to gather all transactions at the expense of having to trust the centralized service to be up all the time and to not be corrupt.</p></li>
</ol>

<p>Any way you slice it, you cannot get the transaction data from a python library that doesn't connect to some other service. Hence tools like pybitcointools or pycoin will not get you what you need. sx has some tools to look up utxos using method #3.</p>

<p>You can install Armory or bitcoind and import the private key and use method #1 above or use something like <a href="http://www.pi-wallet.com" rel="nofollow">pi-wallet</a> and use method #2.</p>
