bitcoin get raw transaction

commits branch releases contributors MIT Latest commit 74734bf Dec 11, 2013 Merge pull request #11 from ryanxcharles/bug/correct-script-tx-constants Permalink README Build bitcoin transactions -------------------------- Usage: cosign [options] COMMAND [command parameters] Options: -f, --file Load/store transaction state to/from FILE Theory of operation ------------------- All operation revolves around an internal database, which is modified via execution of a command operation: 1. cosign reads transaction state file (JSON).2. cosign executes command given on command line, updating transaction state.3. cosign writes transaction state file, overwriting previous version."transaction state" is anything involving the given transaction being built, examined or modified.A session begins when a new database is initialized, using the "init" command.Dependencies ------------ / node modules ("npm install $module_name"): optimist /gasteve/node-libcoin cosign command summary ---------------------- If the command notes "(RPC)", that indicates bitcoind wallet and RPC are used.

inputs.clear Clear list of TX inputs.multisig N-REQUIRED KEY1 KEY2 KEY3... Begin new multi-sig tx nreq N-REQUIRED Specify number of sigs required for a multisig tx outputs ADDRESS1 VALUE1 ADDRESS2 VALUE2... Raw transaction building.Append to list of TX outputs.outputs.clear Clear list of TX outputs.pubkey.get ADDRESS Obtain full pubkey, given bitcoin address (pubkey hash), from bitcoind wallet (RPC) or local wallet file (JSON).pubkeys KEY1 KEY2 KEY3... Append to list of pubkeys / bitcoin addresses pubkeys.clear Clear list of pubkeys.raw SERIALIZED-TX Input serialized transaction from command line raw.append FILE Append FILE to in-memory serialized transaction data.raw.clear Clear serialized tx data.raw.create create raw transaction, given inputs and outputs.raw.decode (RPC) decode raw transaction to readable JSON object.raw.get TXID (RPC) get raw transaction, given hash txid.raw.read FILE Input serialized transaction from file.

raw.send (RPC) broadcast raw transaction to network, returning a transaction id.raw.sign [anyonecanpay] (RPC) sign raw transaction, if possible.Uses keys in bitcoind's wallet.If the optional argument "anyonecanpay" is supplied, outputs are locked, but third party inputs may change.raw.write FILE Output serialized transaction to file.wallet.msig (RPC, JSON) Commit in-memory multisig data (N-Required, Keys) to wallet, returning a multisig payment address.Encryption (walletpassphrase) note ---------------------------------- The user is expected to authenticate with bitcoind RPC prior to using this tool, if this tool will require access to private keys for the operation (e.g.Jump to: , Contents 1 2 3 4 5 The "raw transaction API" was introduced with Bitcoin-Qt/bitcoind version 0.7.It gives developers or very sophisticated end-users low-level access to transaction creation and broadcast.Returns an array of unspent transaction outputs in the wallet that have between minconf and maxconf (inclusive) confirmations.

Each output is a 5-element object with keys: txid, output, scriptPubKey, amount, confirmations.txid is the hexadecimal transaction id, output is which output of that transaction, scriptPubKey is the hexadecimal-encoded CScript for that output, amount is the value of that output and confirmations is the transaction's depth in the chain.Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.A locked transaction output will not be chosen by automatic coin selection, when spending bitcoins.Locks are stored in memory only.Nodes start with zero locked outputs, and the locked output list is always cleared (by virtue of process exit) when a node stops or fails.List all temporarily locked transaction outputs.Create a transaction spending given inputs (array of objects containing transaction outputs to spend), sending to given address(es).Returns the hex-encoded transaction in a string.Note that the transaction's inputs are not signed, and it is not stored in the wallet or transmitted to the network.

Also note that NO transaction validity checks are done; it is easy to create invalid transactions or transactions that will not be relayed/mined by the network because they contain insufficient fees.Returns JSON object with information about a serialized, hex-encoded transaction.If verbose=0, returns serialized, hex-encoded data for transaction txid.If verbose is non-zero, returns a JSON Object containing information about the transaction.Returns an error if
is unknown.Sign as many inputs as possible for raw transaction (serialized, hex-encoded).The first argument may be several variations of the same transaction concatenated together; signatures from all of them will be combined together, along with signatures for keys in the local wallet.The optional second argument is an array of parent transaction outputs, so you can create a chain of raw transactions that depend on each other before sending them to the network.Third optional argument is an array of base58-encoded private keys that, if given, will be the only keys used to sign the transaction.

The fourth optional argument is a string that specifies how the signature hash is computed, and can be "ALL", "NONE", "SINGLE", "ALL|ANYONECANPAY", "NONE|ANYONECANPAY", or "SINGLE|ANYONECANPAY".Returns json object with keys: If no private keys are given and the wallet is locked, requires that the wallet be unlocked with walletpassphrase first.Submits raw transaction (serialized, hex-encoded) to local node and network.Returns transaction id, or an error if the transaction is invalid for any reason.Funds are sitting in one or more multisignature transaction outputs, and it is time to gather signatures and spend them.Assumption: you know the multisignature outputs' {txid, outputNumber, amount}.You must be careful to include an appropriate transaction fee, or the sendrawtransaction method is likely to fail (either immediately or, worse, the transaction will never confirm).These lower-level routines will be useful for debugging and testing; listunspent gives a detailed list of the state of the wallet, and sendrawtx might be used to test double-spend-handling.

You want fine-grained control over exactly what coins in the wallet are spent.Note that you are responsible for preventing accidental double-spends.You want to specify, on a per-transaction basis, how much to pay in fees.Or you want to implement your own policy for how often transactions that are not immediately included in blocks are re-broadcast to the network.If you want to re-broadcast a transaction right away, you can use the getrawtransaction and sendrawtransaction API calls to do that.As a bash shell-script one-liner it would be: (note that Bitcoin-Qt/bitcoind automatically re-transmit wallet transactions periodically until they are accepted into a block).If you have a raw transaction and want to make sure all of its signatures are correct, you can use the signrawtransaction API call.Pass in the hex-encoded raw transaction, any inputs that bitcoind doesn't yet know about, and an empty array of private keys to use to sign the transaction.Passing an empty array of private keys will prevent signrawtransaction from doing any signing; if it returns "complete":1 then all of the existing signatures are valid and there are no signatures missing.