Created
February 21, 2017 18:24
-
-
Save alexbosworth/af7a065032daf2e31d3481c01a75a730 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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