Skip to content

Commit 71ef7d1

Browse files
committed
add optional InternalPk to Beneficiary::WitnessVout
1 parent d3e40d6 commit 71ef7d1

File tree

5 files changed

+170
-55
lines changed

5 files changed

+170
-55
lines changed

Cargo.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/src/command.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ impl Exec for RgbArgs {
728728
.next()
729729
.expect("no addresses left")
730730
.addr;
731-
Beneficiary::WitnessVout(Pay2Vout::new(addr.payload))
731+
Beneficiary::WitnessVout(Pay2Vout::new(addr.payload), None)
732732
}
733733
(_, Some(outpoint)) => {
734734
let seal = GraphSeal::new_random(outpoint.txid, outpoint.vout);

psbt/src/rgb.rs

+24
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ pub const PSBT_GLOBAL_RGB_TRANSITION: u64 = 0x01;
4949
/// Proprietary key subtype for storing information on which close method
5050
/// should be used.
5151
pub const PSBT_GLOBAL_RGB_CLOSE_METHOD: u64 = 0x02;
52+
/// Proprietary key subtype to signal that tapret host has been put on change.
53+
pub const PSBT_GLOBAL_RGB_TAP_HOST_CHANGE: u64 = 0x03;
5254
/// Proprietary key subtype for storing RGB state transition operation id which
5355
/// consumes this input.
5456
pub const PSBT_IN_RGB_CONSUMED_BY: u64 = 0x01;
@@ -99,6 +101,7 @@ pub trait ProprietaryKeyRgb {
99101
data: opid.to_vec().into(),
100102
}
101103
}
104+
102105
/// Constructs [`PSBT_GLOBAL_RGB_CLOSE_METHOD`] proprietary key.
103106
fn rgb_close_method() -> PropKey {
104107
PropKey {
@@ -116,6 +119,15 @@ pub trait ProprietaryKeyRgb {
116119
data: contract_id.to_vec().into(),
117120
}
118121
}
122+
123+
/// Constructs [`PSBT_GLOBAL_RGB_TAP_HOST_CHANGE`] proprietary key.
124+
fn rgb_tapret_host_on_change() -> PropKey {
125+
PropKey {
126+
identifier: PSBT_RGB_PREFIX.to_owned(),
127+
subtype: PSBT_GLOBAL_RGB_TAP_HOST_CHANGE,
128+
data: none!(),
129+
}
130+
}
119131
}
120132

121133
impl ProprietaryKeyRgb for PropKey {}
@@ -193,8 +205,12 @@ pub trait RgbExt {
193205

194206
fn rgb_close_method(&self) -> Result<Option<CloseMethod>, RgbPsbtError>;
195207

208+
fn rgb_tapret_host_on_change(&self) -> bool;
209+
196210
fn set_rgb_close_method(&mut self, close_method: CloseMethod);
197211

212+
fn set_rgb_tapret_host_on_change(&mut self);
213+
198214
fn push_rgb_transition(&mut self, transition: Transition) -> Result<bool, RgbPsbtError>;
199215

200216
fn rgb_bundles(&self) -> Result<BTreeMap<ContractId, TransitionBundle>, RgbPsbtError> {
@@ -299,10 +315,18 @@ impl RgbExt for Psbt {
299315
Err(RgbPsbtError::InvalidCloseMethod)
300316
}
301317

318+
fn rgb_tapret_host_on_change(&self) -> bool {
319+
self.has_proprietary(&PropKey::rgb_tapret_host_on_change())
320+
}
321+
302322
fn set_rgb_close_method(&mut self, close_method: CloseMethod) {
303323
let _ = self.push_proprietary(PropKey::rgb_close_method(), vec![close_method as u8]);
304324
}
305325

326+
fn set_rgb_tapret_host_on_change(&mut self) {
327+
let _ = self.push_proprietary(PropKey::rgb_tapret_host_on_change(), vec![]);
328+
}
329+
306330
fn push_rgb_transition(&mut self, mut transition: Transition) -> Result<bool, RgbPsbtError> {
307331
let opid = transition.id();
308332

src/errors.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ pub enum WalletError {
8585
#[display(doc_comments)]
8686
IncompleteContract(validation::Status),
8787

88+
/// cannot find the terminal to add the tapret tweak to.
89+
NoTweakTerminal,
90+
8891
/// resolver error: {0}
8992
#[display(doc_comments)]
9093
Resolver(String),
@@ -147,11 +150,6 @@ pub enum CompositionError {
147150
/// invoice requesting chain-network pair {0} but contract commits to a different one ({1})
148151
InvoiceBeneficiaryWrongChainNet(ChainNet, ChainNet),
149152

150-
/// one of the RGB assignments spent require presence of tapret output -
151-
/// even this is not a taproot wallet. Unable to create a valid PSBT, manual
152-
/// work is needed.
153-
TapretRequired,
154-
155153
/// non-fungible state is not yet supported by the invoices.
156154
Unsupported,
157155

@@ -170,6 +168,9 @@ pub enum CompositionError {
170168
/// no outputs available to store state of type {0}
171169
NoExtraOrChange(AssignmentType),
172170

171+
/// cannot find an output where to put the tapret commitment.
172+
NoOutputForTapretCommitment,
173+
173174
/// the provided PSBT doesn't pay any sats to the RGB beneficiary address.
174175
NoBeneficiaryOutput,
175176

0 commit comments

Comments
 (0)