Skip to content

Commit 9510700

Browse files
authored
Merge pull request #232 from dcSpark/cip2-coin-selection
TxBuilder: Implement CIP-0002 Coin Selection
2 parents 78b6421 + fb3fe1c commit 9510700

File tree

7 files changed

+326
-20
lines changed

7 files changed

+326
-20
lines changed

rust/Cargo.lock

Lines changed: 65 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ num-bigint = "0.4.0"
3030
# feature or this one
3131
clear_on_drop = { version = "0.2", features = ["no_cc"] }
3232
itertools = "0.10.1"
33+
rand = "0.8.4"
3334

3435
# non-wasm
3536
[target.'cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))'.dependencies]

rust/src/address.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl Deserialize for StakeCredential {
167167
}
168168
}
169169

170-
#[derive(Debug, Clone)]
170+
#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)]
171171
enum AddrType {
172172
Base(BaseAddress),
173173
Ptr(PointerAddress),
@@ -177,7 +177,7 @@ enum AddrType {
177177
}
178178

179179
#[wasm_bindgen]
180-
#[derive(Clone, Debug)]
180+
#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)]
181181
pub struct ByronAddress(pub (crate) ExtendedAddr);
182182
#[wasm_bindgen]
183183
impl ByronAddress {
@@ -264,7 +264,7 @@ impl ByronAddress {
264264
}
265265

266266
#[wasm_bindgen]
267-
#[derive(Debug, Clone)]
267+
#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)]
268268
pub struct Address(AddrType);
269269

270270
from_bytes!(Address, data, {

rust/src/legacy_address/address.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl cbor_event::de::Deserialize for AddrType {
7676

7777
type HDAddressPayload = Vec<u8>;
7878

79-
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
79+
#[derive(Debug, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
8080
pub struct Attributes {
8181
pub derivation_path: Option<HDAddressPayload>,
8282
pub protocol_magic: Option<u32>,
@@ -182,10 +182,10 @@ fn hash_spending_data(addr_type: AddrType, xpub: &XPub, attrs: &Attributes) -> [
182182
}
183183

184184
/// A valid cardano Address that is displayed in base58
185-
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
185+
#[derive(Debug, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
186186
pub struct Addr(Vec<u8>);
187187

188-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
188+
#[derive(Debug, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
189189
pub enum AddressMatchXPub {
190190
Yes,
191191
No,
@@ -277,7 +277,7 @@ impl cbor_event::de::Deserialize for Addr {
277277
const EXTENDED_ADDR_LEN: usize = 28;
278278

279279
/// A valid cardano address deconstructed
280-
#[derive(Debug, PartialEq, Eq, Clone)]
280+
#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)]
281281
pub struct ExtendedAddr {
282282
pub addr: [u8; EXTENDED_ADDR_LEN],
283283
pub attributes: Attributes,

rust/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl TransactionInput {
383383
}
384384

385385
#[wasm_bindgen]
386-
#[derive(Clone, Debug)]
386+
#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)]
387387
pub struct TransactionOutput {
388388
address: Address,
389389
pub (crate) amount: Value,

0 commit comments

Comments
 (0)