constructScriptSig function

Uint8List constructScriptSig({
  1. required HDWalletPurpose walletPurpose,
  2. required Uint8List signature,
  3. required Uint8List publicKey,
  4. Uint8List? redeemScript,
})

Implementation

Uint8List constructScriptSig({
  required HDWalletPurpose walletPurpose,
  required Uint8List signature,
  required Uint8List publicKey,
  Uint8List? redeemScript, // Required for BIP49 (P2SH-P2WPKH)
}) =>
    switch (walletPurpose) {
      HDWalletPurpose.NO_STRUCTURE ||
      HDWalletPurpose.BIP44 =>
        Uint8List.fromList([
          signature.length,
          ...signature,
          publicKey.length,
          ...publicKey,
        ]),
      HDWalletPurpose.BIP49 => Uint8List.fromList([
          0x00,
          signature.length,
          ...signature,
          redeemScript!.length,
          ...redeemScript,
        ]),

      /// Should never be called as it is handled in constructWitnessScript
      HDWalletPurpose.BIP84 => Uint8List.fromList([
          0x00,
          signature.length,
          ...signature,
          publicKey.length,
          ...publicKey,
        ]),
    };