Skip to content

Commit 9ea3c28

Browse files
committed
Merge tcharding/rust-psbt#94: Handle multi byte keytypes in Key::decode and Key::encode
3d23615 fix: handle multi byte keytypes in Key::decode and Key::encode (nymius) d47ab6d fix: encode keytype as u64 instead of u8 (nymius) Pull request description: `<keytype>` as specified by BIP 174 may be represented with up to 8 bytes, even if minimally encoded. Because the currently specified fields weren't using as many bytes, we were only considering the single byte case in the `Key::decode` and `Key::encode` logic. Here we change this logic to address larger `<keytypes>` and follow the specification. Stacks on top of: #90, #93. Fixes #78. ACKs for top commit: nyonson: ACK 3d23615 tcharding: ACK 3d23615 Tree-SHA512: f6d12532eabd702979020835f23f7e588620014f8850e15d02dcbea20f253eea894f5a9f36b95d66a55f0e38a3b6a6701e8ca06aff88f6c70eb57600d59c9ef1
2 parents cef526e + 3d23615 commit 9ea3c28

9 files changed

Lines changed: 139 additions & 120 deletions

File tree

src/consts.rs

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,117 +8,117 @@
88
#![allow(dead_code)]
99

1010
/// Type: Unsigned Transaction PSBT_GLOBAL_UNSIGNED_TX = 0x00
11-
pub(crate) const PSBT_GLOBAL_UNSIGNED_TX: u8 = 0x00;
11+
pub(crate) const PSBT_GLOBAL_UNSIGNED_TX: u64 = 0x00;
1212
/// Type: Extended Public Key PSBT_GLOBAL_XPUB = 0x01
13-
pub(crate) const PSBT_GLOBAL_XPUB: u8 = 0x01;
13+
pub(crate) const PSBT_GLOBAL_XPUB: u64 = 0x01;
1414
/// Type: Transaction Version PSBT_GLOBAL_TX_VERSION = 0x02
15-
pub(crate) const PSBT_GLOBAL_TX_VERSION: u8 = 0x02;
15+
pub(crate) const PSBT_GLOBAL_TX_VERSION: u64 = 0x02;
1616
/// Type: Fallback Locktime PSBT_GLOBAL_FALLBACK_LOCKTIME = 0x03
17-
pub(crate) const PSBT_GLOBAL_FALLBACK_LOCKTIME: u8 = 0x03;
17+
pub(crate) const PSBT_GLOBAL_FALLBACK_LOCKTIME: u64 = 0x03;
1818
/// Type: Input Count PSBT_GLOBAL_INPUT_COUNT = 0x04
19-
pub(crate) const PSBT_GLOBAL_INPUT_COUNT: u8 = 0x04;
19+
pub(crate) const PSBT_GLOBAL_INPUT_COUNT: u64 = 0x04;
2020
/// Type: Output Count PSBT_GLOBAL_OUTPUT_COUNT = 0x05
21-
pub(crate) const PSBT_GLOBAL_OUTPUT_COUNT: u8 = 0x05;
21+
pub(crate) const PSBT_GLOBAL_OUTPUT_COUNT: u64 = 0x05;
2222
/// Type: Transaction Modifiable Flags PSBT_GLOBAL_TX_MODIFIABLE = 0x06
23-
pub(crate) const PSBT_GLOBAL_TX_MODIFIABLE: u8 = 0x06;
23+
pub(crate) const PSBT_GLOBAL_TX_MODIFIABLE: u64 = 0x06;
2424
#[cfg(feature = "silent-payments")]
2525
/// Type: Silent Payment ECDH Share PSBT_GLOBAL_SP_ECDH_SHARE = 0x07
26-
pub(crate) const PSBT_GLOBAL_SP_ECDH_SHARE: u8 = 0x07;
26+
pub(crate) const PSBT_GLOBAL_SP_ECDH_SHARE: u64 = 0x07;
2727
#[cfg(feature = "silent-payments")]
2828
/// Type: Silent Payment DLEQ PSBT_GLOBAL_SP_DLEQ = 0x08
29-
pub(crate) const PSBT_GLOBAL_SP_DLEQ: u8 = 0x08;
29+
pub(crate) const PSBT_GLOBAL_SP_DLEQ: u64 = 0x08;
3030
/// Type: Version Number PSBT_GLOBAL_VERSION = 0xFB
31-
pub(crate) const PSBT_GLOBAL_VERSION: u8 = 0xFB;
31+
pub(crate) const PSBT_GLOBAL_VERSION: u64 = 0xFB;
3232
/// Type: Proprietary Use Type PSBT_GLOBAL_PROPRIETARY = 0xFC
33-
pub(crate) const PSBT_GLOBAL_PROPRIETARY: u8 = 0xFC;
33+
pub(crate) const PSBT_GLOBAL_PROPRIETARY: u64 = 0xFC;
3434

3535
/// Type: Non-Witness UTXO PSBT_IN_NON_WITNESS_UTXO = 0x00
36-
pub(crate) const PSBT_IN_NON_WITNESS_UTXO: u8 = 0x00;
36+
pub(crate) const PSBT_IN_NON_WITNESS_UTXO: u64 = 0x00;
3737
/// Type: Witness UTXO PSBT_IN_WITNESS_UTXO = 0x01
38-
pub(crate) const PSBT_IN_WITNESS_UTXO: u8 = 0x01;
38+
pub(crate) const PSBT_IN_WITNESS_UTXO: u64 = 0x01;
3939
/// Type: Partial Signature PSBT_IN_PARTIAL_SIG = 0x02
40-
pub(crate) const PSBT_IN_PARTIAL_SIG: u8 = 0x02;
40+
pub(crate) const PSBT_IN_PARTIAL_SIG: u64 = 0x02;
4141
/// Type: Sighash Type PSBT_IN_SIGHASH_TYPE = 0x03
42-
pub(crate) const PSBT_IN_SIGHASH_TYPE: u8 = 0x03;
42+
pub(crate) const PSBT_IN_SIGHASH_TYPE: u64 = 0x03;
4343
/// Type: Redeem Script PSBT_IN_REDEEM_SCRIPT = 0x04
44-
pub(crate) const PSBT_IN_REDEEM_SCRIPT: u8 = 0x04;
44+
pub(crate) const PSBT_IN_REDEEM_SCRIPT: u64 = 0x04;
4545
/// Type: Witness Script PSBT_IN_WITNESS_SCRIPT = 0x05
46-
pub(crate) const PSBT_IN_WITNESS_SCRIPT: u8 = 0x05;
46+
pub(crate) const PSBT_IN_WITNESS_SCRIPT: u64 = 0x05;
4747
/// Type: BIP 32 Derivation Path PSBT_IN_BIP32_DERIVATION = 0x06
48-
pub(crate) const PSBT_IN_BIP32_DERIVATION: u8 = 0x06;
48+
pub(crate) const PSBT_IN_BIP32_DERIVATION: u64 = 0x06;
4949
/// Type: Finalized scriptSig PSBT_IN_FINAL_SCRIPTSIG = 0x07
50-
pub(crate) const PSBT_IN_FINAL_SCRIPTSIG: u8 = 0x07;
50+
pub(crate) const PSBT_IN_FINAL_SCRIPTSIG: u64 = 0x07;
5151
/// Type: Finalized scriptWitness PSBT_IN_FINAL_SCRIPTWITNESS = 0x08
52-
pub(crate) const PSBT_IN_FINAL_SCRIPTWITNESS: u8 = 0x08;
52+
pub(crate) const PSBT_IN_FINAL_SCRIPTWITNESS: u64 = 0x08;
5353
/// Type: Proof-of-reserves commitment PSBT_IN_POR_COMMITMENT = 0x09
5454
#[allow(unused)] // PSBT v0
55-
pub(crate) const PSBT_IN_POR_COMMITMENT: u8 = 0x09;
55+
pub(crate) const PSBT_IN_POR_COMMITMENT: u64 = 0x09;
5656
/// Type: RIPEMD160 preimage PSBT_IN_RIPEMD160 = 0x0a
57-
pub(crate) const PSBT_IN_RIPEMD160: u8 = 0x0a;
57+
pub(crate) const PSBT_IN_RIPEMD160: u64 = 0x0a;
5858
/// Type: SHA256 preimage PSBT_IN_SHA256 = 0x0b
59-
pub(crate) const PSBT_IN_SHA256: u8 = 0x0b;
59+
pub(crate) const PSBT_IN_SHA256: u64 = 0x0b;
6060
/// Type: HASH160 preimage PSBT_IN_HASH160 = 0x0c
61-
pub(crate) const PSBT_IN_HASH160: u8 = 0x0c;
61+
pub(crate) const PSBT_IN_HASH160: u64 = 0x0c;
6262
/// Type: HASH256 preimage PSBT_IN_HASH256 = 0x0d
63-
pub(crate) const PSBT_IN_HASH256: u8 = 0x0d;
63+
pub(crate) const PSBT_IN_HASH256: u64 = 0x0d;
6464
/// Type: Previous TXID PSBT_IN_PREVIOUS_TXID = 0x0e
65-
pub(crate) const PSBT_IN_PREVIOUS_TXID: u8 = 0x0e;
65+
pub(crate) const PSBT_IN_PREVIOUS_TXID: u64 = 0x0e;
6666
/// Type: Spent Output Index PSBT_IN_OUTPUT_INDEX = 0x0f
67-
pub(crate) const PSBT_IN_OUTPUT_INDEX: u8 = 0x0f;
67+
pub(crate) const PSBT_IN_OUTPUT_INDEX: u64 = 0x0f;
6868
/// Type: Sequence Number PSBT_IN_SEQUENCE = 0x10
69-
pub(crate) const PSBT_IN_SEQUENCE: u8 = 0x10;
69+
pub(crate) const PSBT_IN_SEQUENCE: u64 = 0x10;
7070
/// Type: Required Time-based Locktime PSBT_IN_REQUIRED_TIME_LOCKTIME = 0x11
71-
pub(crate) const PSBT_IN_REQUIRED_TIME_LOCKTIME: u8 = 0x11;
71+
pub(crate) const PSBT_IN_REQUIRED_TIME_LOCKTIME: u64 = 0x11;
7272
/// Type: Required Height-based Locktime PSBT_IN_REQUIRED_HEIGHT_LOCKTIME = 0x12
73-
pub(crate) const PSBT_IN_REQUIRED_HEIGHT_LOCKTIME: u8 = 0x12;
73+
pub(crate) const PSBT_IN_REQUIRED_HEIGHT_LOCKTIME: u64 = 0x12;
7474
/// Type: Taproot Signature in Key Spend PSBT_IN_TAP_KEY_SIG = 0x13
75-
pub(crate) const PSBT_IN_TAP_KEY_SIG: u8 = 0x13;
75+
pub(crate) const PSBT_IN_TAP_KEY_SIG: u64 = 0x13;
7676
/// Type: Taproot Signature in Script Spend PSBT_IN_TAP_SCRIPT_SIG = 0x14
77-
pub(crate) const PSBT_IN_TAP_SCRIPT_SIG: u8 = 0x14;
77+
pub(crate) const PSBT_IN_TAP_SCRIPT_SIG: u64 = 0x14;
7878
/// Type: Taproot Leaf Script PSBT_IN_TAP_LEAF_SCRIPT = 0x14
79-
pub(crate) const PSBT_IN_TAP_LEAF_SCRIPT: u8 = 0x15;
79+
pub(crate) const PSBT_IN_TAP_LEAF_SCRIPT: u64 = 0x15;
8080
/// Type: Taproot Key BIP 32 Derivation Path PSBT_IN_TAP_BIP32_DERIVATION = 0x16
81-
pub(crate) const PSBT_IN_TAP_BIP32_DERIVATION: u8 = 0x16;
81+
pub(crate) const PSBT_IN_TAP_BIP32_DERIVATION: u64 = 0x16;
8282
/// Type: Taproot Internal Key PSBT_IN_TAP_INTERNAL_KEY = 0x17
83-
pub(crate) const PSBT_IN_TAP_INTERNAL_KEY: u8 = 0x17;
83+
pub(crate) const PSBT_IN_TAP_INTERNAL_KEY: u64 = 0x17;
8484
/// Type: Taproot Merkle Root PSBT_IN_TAP_MERKLE_ROOT = 0x18
85-
pub(crate) const PSBT_IN_TAP_MERKLE_ROOT: u8 = 0x18;
85+
pub(crate) const PSBT_IN_TAP_MERKLE_ROOT: u64 = 0x18;
8686
#[cfg(feature = "silent-payments")]
8787
/// Type: Silent Payment ECDH Share PSBT_IN_SP_ECDH_SHARE = 0x1D
88-
pub(crate) const PSBT_IN_SP_ECDH_SHARE: u8 = 0x1D;
88+
pub(crate) const PSBT_IN_SP_ECDH_SHARE: u64 = 0x1D;
8989
#[cfg(feature = "silent-payments")]
9090
/// Type: Silent Payment DLEQ Proof PSBT_IN_SP_DLEQ = 0x1E
91-
pub(crate) const PSBT_IN_SP_DLEQ: u8 = 0x1E;
91+
pub(crate) const PSBT_IN_SP_DLEQ: u64 = 0x1E;
9292
/// Type: Proprietary Use Type PSBT_IN_PROPRIETARY = 0xFC
93-
pub(crate) const PSBT_IN_PROPRIETARY: u8 = 0xFC;
93+
pub(crate) const PSBT_IN_PROPRIETARY: u64 = 0xFC;
9494

9595
/// Type: Redeem ScriptBuf PSBT_OUT_REDEEM_SCRIPT = 0x00
96-
pub(crate) const PSBT_OUT_REDEEM_SCRIPT: u8 = 0x00;
96+
pub(crate) const PSBT_OUT_REDEEM_SCRIPT: u64 = 0x00;
9797
/// Type: Witness ScriptBuf PSBT_OUT_WITNESS_SCRIPT = 0x01
98-
pub(crate) const PSBT_OUT_WITNESS_SCRIPT: u8 = 0x01;
98+
pub(crate) const PSBT_OUT_WITNESS_SCRIPT: u64 = 0x01;
9999
/// Type: BIP 32 Derivation Path PSBT_OUT_BIP32_DERIVATION = 0x02
100-
pub(crate) const PSBT_OUT_BIP32_DERIVATION: u8 = 0x02;
100+
pub(crate) const PSBT_OUT_BIP32_DERIVATION: u64 = 0x02;
101101
/// Type: Output Amount PSBT_OUT_AMOUNT = 0x03
102-
pub(crate) const PSBT_OUT_AMOUNT: u8 = 0x03;
102+
pub(crate) const PSBT_OUT_AMOUNT: u64 = 0x03;
103103
/// Type: Output Script PSBT_OUT_SCRIPT = 0x04
104-
pub(crate) const PSBT_OUT_SCRIPT: u8 = 0x04;
104+
pub(crate) const PSBT_OUT_SCRIPT: u64 = 0x04;
105105
/// Type: Taproot Internal Key PSBT_OUT_TAP_INTERNAL_KEY = 0x05
106-
pub(crate) const PSBT_OUT_TAP_INTERNAL_KEY: u8 = 0x05;
106+
pub(crate) const PSBT_OUT_TAP_INTERNAL_KEY: u64 = 0x05;
107107
/// Type: Taproot Tree PSBT_OUT_TAP_TREE = 0x06
108-
pub(crate) const PSBT_OUT_TAP_TREE: u8 = 0x06;
108+
pub(crate) const PSBT_OUT_TAP_TREE: u64 = 0x06;
109109
/// Type: Taproot Key BIP 32 Derivation Path PSBT_OUT_TAP_BIP32_DERIVATION = 0x07
110-
pub(crate) const PSBT_OUT_TAP_BIP32_DERIVATION: u8 = 0x07;
110+
pub(crate) const PSBT_OUT_TAP_BIP32_DERIVATION: u64 = 0x07;
111111
#[cfg(feature = "silent-payments")]
112112
/// Type: Silent Payment v0 Info PSBT_OUT_SP_V0_INFO = 0x09
113-
pub(crate) const PSBT_OUT_SP_V0_INFO: u8 = 0x09;
113+
pub(crate) const PSBT_OUT_SP_V0_INFO: u64 = 0x09;
114114
#[cfg(feature = "silent-payments")]
115115
/// Type: Silent Payment v0 Label PSBT_OUT_SP_V0_LABEL = 0x0A
116-
pub(crate) const PSBT_OUT_SP_V0_LABEL: u8 = 0x0A;
116+
pub(crate) const PSBT_OUT_SP_V0_LABEL: u64 = 0x0A;
117117
/// Type: Proprietary Use Type PSBT_IN_PROPRIETARY = 0xFC
118-
pub(crate) const PSBT_OUT_PROPRIETARY: u8 = 0xFC;
118+
pub(crate) const PSBT_OUT_PROPRIETARY: u64 = 0xFC;
119119

120120
/// Converts a global key type value consts to a string, useful for debugging.
121-
pub(crate) fn psbt_global_key_type_value_to_str(v: u8) -> &'static str {
121+
pub(crate) fn psbt_global_key_type_value_to_str(v: u64) -> &'static str {
122122
match v {
123123
PSBT_GLOBAL_UNSIGNED_TX => "PSBT_GLOBAL_UNSIGNED_TX",
124124
PSBT_GLOBAL_XPUB => "PSBT_GLOBAL_XPUB",
@@ -138,7 +138,7 @@ pub(crate) fn psbt_global_key_type_value_to_str(v: u8) -> &'static str {
138138
}
139139

140140
/// Converts an input key type value consts to a string, useful for debugging.
141-
pub(crate) fn psbt_in_key_type_value_to_str(v: u8) -> &'static str {
141+
pub(crate) fn psbt_in_key_type_value_to_str(v: u64) -> &'static str {
142142
match v {
143143
PSBT_IN_NON_WITNESS_UTXO => "PSBT_IN_NON_WITNESS_UTXO",
144144
PSBT_IN_WITNESS_UTXO => "PSBT_IN_WITNESS_UTXO",
@@ -175,7 +175,7 @@ pub(crate) fn psbt_in_key_type_value_to_str(v: u8) -> &'static str {
175175
}
176176

177177
/// Converts an output key type value consts to a string, useful for debugging.
178-
pub(crate) fn psbt_out_key_type_value_to_str(v: u8) -> &'static str {
178+
pub(crate) fn psbt_out_key_type_value_to_str(v: u64) -> &'static str {
179179
match v {
180180
PSBT_OUT_REDEEM_SCRIPT => "PSBT_OUT_REDEEM_SCRIPT",
181181
PSBT_OUT_WITNESS_SCRIPT => "PSBT_OUT_WITNESS_SCRIPT",

src/raw.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl Deserialize for Pair {
7777
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
7878
pub struct Key {
7979
/// The `keytype` of this PSBT map key (`keytype`).
80-
pub type_value: u8,
80+
pub type_value: u64,
8181
/// The `keydata` itself in raw byte form.
8282
#[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::hex_bytes"))]
8383
pub key: Vec<u8>,
@@ -91,7 +91,18 @@ impl Key {
9191
return Err(serialize::Error::NoMorePairs);
9292
}
9393

94-
let key_byte_size: u64 = byte_size - 1;
94+
let type_value: VarInt = Decodable::consensus_decode(r)?;
95+
96+
let key_byte_size = match byte_size.checked_sub(
97+
u64::try_from(type_value.size()).expect("size() returns 1-9, fits inside u64"),
98+
) {
99+
Some(val) => val,
100+
None => {
101+
return Err(consensus::Error::ParseFailed(
102+
"encoded keytype is larger than specified length",
103+
))?;
104+
}
105+
};
95106

96107
if key_byte_size > MAX_VEC_SIZE as u64 {
97108
return Err(consensus::Error::OversizedVectorAllocation {
@@ -101,25 +112,24 @@ impl Key {
101112
.into());
102113
}
103114

104-
let type_value: u8 = Decodable::consensus_decode(r)?;
105-
106115
let mut key = Vec::with_capacity(key_byte_size as usize);
107116
for _ in 0..key_byte_size {
108117
key.push(Decodable::consensus_decode(r)?);
109118
}
110119

111-
Ok(Key { type_value, key })
120+
Ok(Key { type_value: type_value.0, key })
112121
}
113122
}
114123

115124
impl Serialize for Key {
116125
fn serialize(&self) -> Vec<u8> {
117126
let mut buf = Vec::new();
118-
VarInt::from(self.key.len() + 1)
127+
let type_value = VarInt::from(self.type_value);
128+
VarInt::from(self.key.len() + type_value.size())
119129
.consensus_encode(&mut buf)
120130
.expect("in-memory writers don't error");
121131

122-
self.type_value.consensus_encode(&mut buf).expect("in-memory writers don't error");
132+
type_value.consensus_encode(&mut buf).expect("in-memory writers don't error");
123133

124134
for key in &self.key {
125135
key.consensus_encode(&mut buf).expect("in-memory writers don't error");

src/v0/bitcoin/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub enum Error {
106106
/// Key must be excluded from this version of PSBT (see consts.rs for u8 values).
107107
ExcludedKey {
108108
/// The disallowed valued.
109-
key_type_value: u8,
109+
key_type_value: u64,
110110
},
111111
}
112112

src/v0/bitcoin/map/global.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,27 @@ use crate::v0::bitcoin::map::Map;
1313
use crate::v0::bitcoin::{raw, Error, Psbt};
1414

1515
/// Type: Unsigned Transaction PSBT_GLOBAL_UNSIGNED_TX = 0x00
16-
const PSBT_GLOBAL_UNSIGNED_TX: u8 = 0x00;
16+
const PSBT_GLOBAL_UNSIGNED_TX: u64 = 0x00;
1717
/// Type: Extended Public Key PSBT_GLOBAL_XPUB = 0x01
18-
const PSBT_GLOBAL_XPUB: u8 = 0x01;
18+
const PSBT_GLOBAL_XPUB: u64 = 0x01;
1919
/// Type: Transaction Version PSBT_GLOBAL_TX_VERSION = 0x02
20-
const PSBT_GLOBAL_TX_VERSION: u8 = 0x02;
20+
const PSBT_GLOBAL_TX_VERSION: u64 = 0x02;
2121
/// Type: Fallback Locktime PSBT_GLOBAL_FALLBACK_LOCKTIME = 0x03
22-
const PSBT_GLOBAL_FALLBACK_LOCKTIME: u8 = 0x03;
22+
const PSBT_GLOBAL_FALLBACK_LOCKTIME: u64 = 0x03;
2323
/// Type: Input Count PSBT_GLOBAL_INPUT_COUNT = 0x04
24-
const PSBT_GLOBAL_INPUT_COUNT: u8 = 0x04;
24+
const PSBT_GLOBAL_INPUT_COUNT: u64 = 0x04;
2525
/// Type: Output Count PSBT_GLOBAL_OUTPUT_COUNT = 0x05
26-
const PSBT_GLOBAL_OUTPUT_COUNT: u8 = 0x05;
26+
const PSBT_GLOBAL_OUTPUT_COUNT: u64 = 0x05;
2727
/// Type: Transaction Modifiable Flags PSBT_GLOBAL_TX_MODIFIABLE = 0x06
28-
const PSBT_GLOBAL_TX_MODIFIABLE: u8 = 0x06;
28+
const PSBT_GLOBAL_TX_MODIFIABLE: u64 = 0x06;
2929
/// Type: Version Number PSBT_GLOBAL_SP_ECDH_SHARE = 0x07
30-
const PSBT_GLOBAL_SP_ECDH_SHARE: u8 = 0x07;
30+
const PSBT_GLOBAL_SP_ECDH_SHARE: u64 = 0x07;
3131
/// Type: Version Number PSBT_GLOBAL_SP_DLEQ = 0x08
32-
const PSBT_GLOBAL_SP_DLEQ: u8 = 0x08;
32+
const PSBT_GLOBAL_SP_DLEQ: u64 = 0x08;
3333
/// Type: Version Number PSBT_GLOBAL_VERSION = 0xFB
34-
const PSBT_GLOBAL_VERSION: u8 = 0xFB;
35-
34+
const PSBT_GLOBAL_VERSION: u64 = 0xFB;
3635
/// Type: Proprietary Use Type PSBT_GLOBAL_PROPRIETARY = 0xFC
37-
const PSBT_GLOBAL_PROPRIETARY: u8 = 0xFC;
36+
const PSBT_GLOBAL_PROPRIETARY: u64 = 0xFC;
3837

3938
impl Map for Psbt {
4039
fn get_pairs(&self) -> Vec<raw::Pair> {

src/v0/bitcoin/map/input.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,59 +20,59 @@ use crate::v0::bitcoin::serialize::Deserialize;
2020
use crate::v0::bitcoin::{self as psbt, error, raw, Error};
2121

2222
/// Type: Non-Witness UTXO PSBT_IN_NON_WITNESS_UTXO = 0x00
23-
const PSBT_IN_NON_WITNESS_UTXO: u8 = 0x00;
23+
const PSBT_IN_NON_WITNESS_UTXO: u64 = 0x00;
2424
/// Type: Witness UTXO PSBT_IN_WITNESS_UTXO = 0x01
25-
const PSBT_IN_WITNESS_UTXO: u8 = 0x01;
25+
const PSBT_IN_WITNESS_UTXO: u64 = 0x01;
2626
/// Type: Partial Signature PSBT_IN_PARTIAL_SIG = 0x02
27-
const PSBT_IN_PARTIAL_SIG: u8 = 0x02;
27+
const PSBT_IN_PARTIAL_SIG: u64 = 0x02;
2828
/// Type: Sighash Type PSBT_IN_SIGHASH_TYPE = 0x03
29-
const PSBT_IN_SIGHASH_TYPE: u8 = 0x03;
29+
const PSBT_IN_SIGHASH_TYPE: u64 = 0x03;
3030
/// Type: Redeem Script PSBT_IN_REDEEM_SCRIPT = 0x04
31-
const PSBT_IN_REDEEM_SCRIPT: u8 = 0x04;
31+
const PSBT_IN_REDEEM_SCRIPT: u64 = 0x04;
3232
/// Type: Witness Script PSBT_IN_WITNESS_SCRIPT = 0x05
33-
const PSBT_IN_WITNESS_SCRIPT: u8 = 0x05;
33+
const PSBT_IN_WITNESS_SCRIPT: u64 = 0x05;
3434
/// Type: BIP 32 Derivation Path PSBT_IN_BIP32_DERIVATION = 0x06
35-
const PSBT_IN_BIP32_DERIVATION: u8 = 0x06;
35+
const PSBT_IN_BIP32_DERIVATION: u64 = 0x06;
3636
/// Type: Finalized scriptSig PSBT_IN_FINAL_SCRIPTSIG = 0x07
37-
const PSBT_IN_FINAL_SCRIPTSIG: u8 = 0x07;
37+
const PSBT_IN_FINAL_SCRIPTSIG: u64 = 0x07;
3838
/// Type: Finalized scriptWitness PSBT_IN_FINAL_SCRIPTWITNESS = 0x08
39-
const PSBT_IN_FINAL_SCRIPTWITNESS: u8 = 0x08;
39+
const PSBT_IN_FINAL_SCRIPTWITNESS: u64 = 0x08;
4040
/// Type: RIPEMD160 preimage PSBT_IN_RIPEMD160 = 0x0a
41-
const PSBT_IN_RIPEMD160: u8 = 0x0a;
41+
const PSBT_IN_RIPEMD160: u64 = 0x0a;
4242
/// Type: SHA256 preimage PSBT_IN_SHA256 = 0x0b
43-
const PSBT_IN_SHA256: u8 = 0x0b;
43+
const PSBT_IN_SHA256: u64 = 0x0b;
4444
/// Type: Previous TXID PSBT_IN_PREVIOUS_TXID = 0x0e
45-
const PSBT_IN_PREVIOUS_TXID: u8 = 0x0e;
45+
const PSBT_IN_PREVIOUS_TXID: u64 = 0x0e;
4646
/// Type: Spent Output Index PSBT_IN_OUTPUT_INDEX = 0x0f
47-
const PSBT_IN_OUTPUT_INDEX: u8 = 0x0f;
47+
const PSBT_IN_OUTPUT_INDEX: u64 = 0x0f;
4848
/// Type: Sequence Number PSBT_IN_SEQUENCE = 0x10
49-
const PSBT_IN_SEQUENCE: u8 = 0x10;
49+
const PSBT_IN_SEQUENCE: u64 = 0x10;
5050
/// Type: Required Time-based Locktime PSBT_IN_REQUIRED_TIME_LOCKTIME = 0x11
51-
const PSBT_IN_REQUIRED_TIME_LOCKTIME: u8 = 0x11;
51+
const PSBT_IN_REQUIRED_TIME_LOCKTIME: u64 = 0x11;
5252
/// Type: Required Height-based Locktime PSBT_IN_REQUIRED_HEIGHT_LOCKTIME = 0x12
53-
const PSBT_IN_REQUIRED_HEIGHT_LOCKTIME: u8 = 0x12;
53+
const PSBT_IN_REQUIRED_HEIGHT_LOCKTIME: u64 = 0x12;
5454
/// Type: HASH160 preimage PSBT_IN_HASH160 = 0x0c
55-
const PSBT_IN_HASH160: u8 = 0x0c;
55+
const PSBT_IN_HASH160: u64 = 0x0c;
5656
/// Type: HASH256 preimage PSBT_IN_HASH256 = 0x0d
57-
const PSBT_IN_HASH256: u8 = 0x0d;
57+
const PSBT_IN_HASH256: u64 = 0x0d;
5858
/// Type: Taproot Signature in Key Spend PSBT_IN_TAP_KEY_SIG = 0x13
59-
const PSBT_IN_TAP_KEY_SIG: u8 = 0x13;
59+
const PSBT_IN_TAP_KEY_SIG: u64 = 0x13;
6060
/// Type: Taproot Signature in Script Spend PSBT_IN_TAP_SCRIPT_SIG = 0x14
61-
const PSBT_IN_TAP_SCRIPT_SIG: u8 = 0x14;
61+
const PSBT_IN_TAP_SCRIPT_SIG: u64 = 0x14;
6262
/// Type: Taproot Leaf Script PSBT_IN_TAP_LEAF_SCRIPT = 0x14
63-
const PSBT_IN_TAP_LEAF_SCRIPT: u8 = 0x15;
63+
const PSBT_IN_TAP_LEAF_SCRIPT: u64 = 0x15;
6464
/// Type: Taproot Key BIP 32 Derivation Path PSBT_IN_TAP_BIP32_DERIVATION = 0x16
65-
const PSBT_IN_TAP_BIP32_DERIVATION: u8 = 0x16;
65+
const PSBT_IN_TAP_BIP32_DERIVATION: u64 = 0x16;
6666
/// Type: Taproot Internal Key PSBT_IN_TAP_INTERNAL_KEY = 0x17
67-
const PSBT_IN_TAP_INTERNAL_KEY: u8 = 0x17;
67+
const PSBT_IN_TAP_INTERNAL_KEY: u64 = 0x17;
6868
/// Type: Taproot Merkle Root PSBT_IN_TAP_MERKLE_ROOT = 0x18
69-
const PSBT_IN_TAP_MERKLE_ROOT: u8 = 0x18;
69+
const PSBT_IN_TAP_MERKLE_ROOT: u64 = 0x18;
7070
/// Type: Silent Payment Elliptic Curve Diffie-Hellman secret share PSBT_IN_SP_ECDH_SHARE = 0x1d
71-
const PSBT_IN_SP_ECDH_SHARE: u8 = 0x1d;
71+
const PSBT_IN_SP_ECDH_SHARE: u64 = 0x1d;
7272
/// Type: Silent Payment Discrete Logarithm Equality Proof PSBT_IN_SP_DLEQ = 0x1e
73-
const PSBT_IN_SP_DLEQ: u8 = 0x1e;
73+
const PSBT_IN_SP_DLEQ: u64 = 0x1e;
7474
/// Type: Proprietary Use Type PSBT_IN_PROPRIETARY = 0xFC
75-
const PSBT_IN_PROPRIETARY: u8 = 0xFC;
75+
const PSBT_IN_PROPRIETARY: u64 = 0xFC;
7676

7777
/// A key-value map for an input of the corresponding index in the unsigned
7878
/// transaction.

0 commit comments

Comments
 (0)