Skip to content

Instantly share code, notes, and snippets.

@alexbosworth
Created February 21, 2017 18:24
Show Gist options
  • Save alexbosworth/af7a065032daf2e31d3481c01a75a730 to your computer and use it in GitHub Desktop.
Save alexbosworth/af7a065032daf2e31d3481c01a75a730 to your computer and use it in GitHub Desktop.
/** Transaction input
*/
struct TransactionInput {
/** Final sequence number marking the input as final
*/
static let finalSequence = UInt32.max
/** Spending output
*/
let outpoint: Outpoint
/** Sequence number
*/
let sequence: UInt32
/** Sequence number byte count
*/
static let sequenceByteCount = 4
/** Spending authorization script
*/
let signatureScript: TransactionScript
}
extension TransactionInput {
/** Serialized version
*/
var hexSerialized: String {
return [
outpoint.transactionId.asInternalByteOrderHex,
outpoint.index.asLittleEndianData.hexEncoded,
signatureScript.stackBytes.count.asCompactSizeUInt.asData.hexEncoded,
Data(signatureScript.stackBytes).hexEncoded,
sequence.asLittleEndianData.hexEncoded
].joined()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment