-
Notifications
You must be signed in to change notification settings - Fork 122
Transaction
A transaction is a signed section of data that is broadcast to the network and collected into blocks. It typically references previous transaction(s) and dedicates a certain number of novacoins from it to one or more new public key(s).
Currently there are a few transaction types possible.
This transactions are typically used to redeem novacoins from unspent inputs. It generally references unspent input(s) and creates a new output(s) with specified value(s) an destination(s).
Coinbase have a single input, and this input has a "coinbase" parameter instead of a scriptSig. The data in "coinbase" can be anything; it isn't used. Novacoin puts the current compact-format target and the arbitrary-precision "extraNonce" number there, which increments every time the Nonce field in the block header overflows. The extranonce contributes to enlarge the domain for the proof of work function.
This transactions are used to reward the proof-of-work miners. Proof-of-stake blocks have the coinbase transaction too, but with empty output.
This transactions are used to provide a suitable proof for proof-of-stake block header. This type is similar to user transactions, but with some differences.
- First output must be empty;
- First input of this transaction is required to satisfy a current proof-of-stake difficulty.
- It's allowed to generate new coins through paying a negative fee.
- A destination of the second output must be Pay-to-Pubkey (described later).
Field | Type | sizeof | Description |
---|---|---|---|
Version | unsigned int | 4 | Currently 1 |
Timestamp | unsigned int | 4 | Transaction timestamp |
Inputs count | variable int | 1 - 9 | - |
Inputs array | TxIn[] | inputs set size | Inputs array or coinbase property |
Outputs count | variable int | 1 - 9 | - |
Outputs array | TxOut[] | outputs set size | Array of output structures |
Lock time | unsigned int | 4 | block height or timestamp when transaction is final |
An input is a reference to an output in a different transaction. Multiple inputs are often listed in a transaction. The values of the referenced outputs are added up, and the total is usable in the outputs of this transaction.
Field | Type | sizeof | Description |
---|---|---|---|
txid | unsigned char[] | 32 | ID of previous transaction |
n | unsigned int | 4 | Number indexing an output of the to-be-consumed transaction |
scriptSigLength | variable int | 1-9 | scriptSig length |
scriptSig | unsigned char[] | - | first half of script, signatures for the scriptPubKey |
nSequence | unsigned int | 4 | Transaction variant number, irrelevant if nLockTime isn't specified. 0xffffffff by default, see this link for a detailed explanation. |
An output contains instructions for sending novacoins. Value is the number of Satoshi (1 NVC = 1,000,000 Satoshi) that this output will be worth when claimed.
Field | Type | sizeof | Description |
---|---|---|---|
nValue | unsigned long int | 8 | the number of Satoshis(NVC/10^6) to be transfered |
scriptPubKeyLength | variable int | 1-9 | scriptPubKey length |
scriptPubKey | unsigned char[] | - | second half of script, spending instructions |
There are three destination types allowed for user and coinbase transactions:
- Public key (Pay-to-Pubkey);
- Public key hash (Pay-to-PubkeyHash);
- Script hash (Pay-to-ScriptHash);
- Empty destination;
- Non-standard script.
scriptPubKey: [pubKey] OP_CHECKSIG
scriptSig: [sig]
scriptPubKey: OP_DUP OP_HASH160 [pubKeyHash] OP_EQUALVERIFY OP_CHECKSIG
scriptSig: [sig] [pubKey]
Send to script hash:
scriptPubKey: OP_HASH160 [20-byte-hash of {[pubkey] OP_CHECKSIG} ] OP_EQUAL
scriptSig: <depending on inputs type>
Redeem example:
scriptPubKey: OP_HASH160 [20-byte-hash of {[pubkey] OP_CHECKSIG} ] OP_EQUAL
scriptSig: [signature] {[pubkey] OP_CHECKSIG}
scriptPubKey: (empty)
scriptSig: (empty)
Anyone-can-spend:
scriptPubKey: (empty)
scriptSig: OP_TRUE