-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Spending Policy API #612
Changes from all commits
61104c6
c6c5eb9
4925a8d
1479893
c79b378
d22510f
437fcd0
2eff412
a4f9a00
e0251b4
2b8592e
269b301
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -401,6 +401,9 @@ interface Wallet { | |
|
||
string descriptor_checksum(KeychainKind keychain); | ||
|
||
[Throws=DescriptorError] | ||
Policy? policies(KeychainKind keychain); | ||
|
||
Balance balance(); | ||
|
||
[Throws=CannotConnectError] | ||
|
@@ -441,6 +444,60 @@ interface Wallet { | |
|
||
interface Update {}; | ||
|
||
interface Policy { | ||
string id(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the only field you need/want for your use case? Just curious really, since we can expose other fields later if needed obv. Regardless, looks good https://docs.rs/bdk_wallet/latest/bdk_wallet/descriptor/policy/struct.Policy.html There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other fields have been exposed now. |
||
|
||
string as_string(); | ||
|
||
boolean requires_path(); | ||
|
||
SatisfiableItem item(); | ||
|
||
Satisfaction satisfaction(); | ||
|
||
Satisfaction contribution(); | ||
}; | ||
|
||
[Enum] | ||
interface SatisfiableItem { | ||
EcdsaSignature(PkOrF key); | ||
SchnorrSignature(PkOrF key); | ||
Sha256Preimage(string hash); | ||
Hash256Preimage(string hash); | ||
Ripemd160Preimage(string hash); | ||
Hash160Preimage(string hash); | ||
AbsoluteTimelock(LockTime value); | ||
RelativeTimelock(u32 value); | ||
Multisig(sequence<PkOrF> keys, u64 threshold); | ||
Thresh(sequence<Policy> items, u64 threshold); | ||
}; | ||
|
||
[Enum] | ||
interface PkOrF { | ||
Pubkey(string value); | ||
XOnlyPubkey(string value); | ||
Fingerprint(string value); | ||
}; | ||
|
||
[Enum] | ||
interface LockTime { | ||
Blocks(u32 height); | ||
Seconds(u32 consensus_time); | ||
}; | ||
|
||
[Enum] | ||
interface Satisfaction { | ||
Partial(u64 n, u64 m, sequence<u64> items, boolean? sorted, record<u32, sequence<Condition>> conditions); | ||
PartialComplete(u64 n, u64 m, sequence<u64> items, boolean? sorted, record<sequence<u32>, sequence<Condition>> conditions); | ||
Complete(Condition condition); | ||
None(string msg); | ||
}; | ||
|
||
dictionary Condition { | ||
u32? csv; | ||
LockTime? timelock; | ||
}; | ||
|
||
interface TxBuilder { | ||
constructor(); | ||
|
||
|
@@ -456,6 +513,8 @@ interface TxBuilder { | |
|
||
TxBuilder add_utxo(OutPoint outpoint); | ||
|
||
TxBuilder policy_path(record<string, sequence<u64>> policy_path, KeychainKind keychain); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is our first use of Looks good https://docs.rs/bdk_wallet/latest/bdk_wallet/tx_builder/struct.TxBuilder.html#method.policy_path There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, thanks! |
||
|
||
TxBuilder change_policy(ChangeSpendPolicy change_policy); | ||
|
||
TxBuilder do_not_spend_change(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good https://docs.rs/bdk_wallet/latest/bdk_wallet/struct.Wallet.html#method.policies