1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
use super::*;

/// Entry point to generate a hierarchical deterministic wallet using the [BIP-0044
/// standard](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki). It is a more structured way to use the same seed for
/// multiple coins, each with multiple accounts, each accounts with a new key for each transaction request. The standard is built on
/// [BIP-0043](https://github.com/bitcoin/bips/blob/master/bip-0043.mediawiki) using the purpose code 44. And BIP-0043 itself uses
/// BIP-0032 to derive all nodes from a single master extended private key.
///
/// @see Bip32
#[wasm_bindgen(js_name = Bip44)]
#[derive(Clone, Debug)]
pub struct JsBip44;

#[wasm_bindgen(js_class = Bip44)]
impl JsBip44 {
    /// Creates the BIP32 root node for a given coin from the given seed based on the network.
    /// We use coin identifiers defined in [SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md).
    ///
    /// @see validateNetworkName, Seed
    pub fn network(seed: &JsSeed, name: &str) -> Result<JsBip44Coin, JsValue> {
        let network = Networks::by_name(name).map_err_to_js()?;
        let coin = Bip44.network(seed.inner(), network).map_err_to_js()?;
        Ok(JsBip44Coin::from(coin))
    }
}

/// Represents a given coin in the BIP32 tree.
///
/// @see Bip32
#[wasm_bindgen(js_name = Bip44Coin)]
#[derive(Clone, Debug)]
pub struct JsBip44Coin {
    inner: Bip44Coin<Secp256k1>,
}

#[wasm_bindgen(js_class = Bip44Coin)]
impl JsBip44Coin {
    /// Returns the underlying {@link Bip32Node}.
    pub fn node(&self) -> JsBip32Node {
        JsBip32Node::from(self.inner.node().clone())
    }

    /// Accessor for the name of the underlying network.
    #[wasm_bindgen(getter)]
    pub fn network(&self) -> String {
        self.inner.network().subtree().name().to_owned()
    }

    /// Creates an account in the coin with the given account index.
    pub fn account(&self, account: i32) -> Result<JsBip44Account, JsValue> {
        let account = self.inner.account(account).map_err_to_js()?;
        Ok(JsBip44Account::from(account))
    }

    /// The coin identifier of the coin, defined in [SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md).
    #[wasm_bindgen(getter = slip44)]
    pub fn slip44(&self) -> i32 {
        self.inner.bip44_path().slip44()
    }

    /// Accessor for the BIP32 path of the coin.
    #[wasm_bindgen(getter = path)]
    pub fn bip32_path(&self) -> String {
        self.inner.bip32_path().to_string()
    }

    // Secp specific methods...

    /// Returns the extended private key in the BIP32 readable format with the version bytes of the network.
    ///
    /// This is a secret that must not be kept unencrypted in transit or in rest!
    #[wasm_bindgen(getter = xprv)]
    pub fn to_xprv(&self) -> String {
        self.inner.to_xprv()
    }
}

impl From<Bip44Coin<Secp256k1>> for JsBip44Coin {
    fn from(inner: Bip44Coin<Secp256k1>) -> Self {
        Self { inner }
    }
}

impl Wraps<Bip44Coin<Secp256k1>> for JsBip44Coin {
    fn inner(&self) -> &Bip44Coin<Secp256k1> {
        &self.inner
    }
}

/// Represents the private API of a given account of a given coin in the BIP32 tree.
#[wasm_bindgen(js_name = Bip44Account)]
#[derive(Clone, Debug)]
pub struct JsBip44Account {
    inner: Bip44Account<Secp256k1>,
}

#[wasm_bindgen(js_class = Bip44Account)]
impl JsBip44Account {
    /// Returns the underlying {@link Bip32Node}.
    pub fn node(&self) -> JsBip32Node {
        JsBip32Node::from(self.inner.node().clone())
    }

    /// Accessor for the name of the underlying network.
    #[wasm_bindgen(getter)]
    pub fn network(&self) -> String {
        self.inner.network().subtree().name().to_owned()
    }

    /// Creates a sub-account for either external keys (receiving addresses) or internal keys (change addresses). This distinction is
    /// a common practice that might help in accounting.
    pub fn chain(&self, change: bool) -> Result<JsBip44SubAccount, JsValue> {
        let account = self.inner.chain(Chain::from(change)).map_err_to_js()?;
        Ok(JsBip44SubAccount::from(account))
    }

    /// Creates a key with a given index used on the chain for storing balance or
    /// authenticating actions. By default these keys are made on the receiving sub-account.
    pub fn key(&self, idx: i32) -> Result<JsBip44Key, JsValue> {
        let sub_account = self.chain(false)?;
        sub_account.key(idx)
    }

    /// The coin identifier of the coin, defined in [SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md).
    #[wasm_bindgen(getter = slip44)]
    pub fn slip44(&self) -> i32 {
        self.inner.bip44_path().parent().slip44()
    }

    /// Accessor for the account index.
    #[wasm_bindgen(getter = account)]
    pub fn account(&self) -> i32 {
        self.inner.bip44_path().account()
    }

    /// Accessor for the BIP32 path of the account.
    #[wasm_bindgen(getter = path)]
    pub fn bip32_path(&self) -> String {
        self.inner.bip32_path().to_string()
    }

    /// Neuters the account and converts it into its public API
    pub fn neuter(&self) -> JsBip44PublicAccount {
        let inner = self.inner.neuter();
        JsBip44PublicAccount::from(inner)
    }

    // Secp specific methods...

    /// Recreates the private API of a BIP44 account from its parts
    #[wasm_bindgen(js_name = fromXprv)]
    pub fn from_xprv(account: i32, xprv: &str, network: &str) -> Result<JsBip44Account, JsValue> {
        let network = Networks::by_name(network).map_err_to_js()?;
        let inner = Bip44Account::from_xprv(account, xprv, network).map_err_to_js()?;
        Ok(JsBip44Account::from(inner))
    }

    /// Returns the extended private key in the BIP32 readable format with the version bytes of the network.
    ///
    /// This is a secret that must not be kept unencrypted in transit or in rest!
    #[wasm_bindgen(getter = xprv)]
    pub fn to_xprv(&self) -> String {
        self.inner.to_xprv()
    }
}

impl From<Bip44Account<Secp256k1>> for JsBip44Account {
    fn from(inner: Bip44Account<Secp256k1>) -> Self {
        Self { inner }
    }
}

impl Wraps<Bip44Account<Secp256k1>> for JsBip44Account {
    fn inner(&self) -> &Bip44Account<Secp256k1> {
        &self.inner
    }
}

/// Represents the public API of a given account of a given coin in the BIP32 tree.
#[wasm_bindgen(js_name = Bip44PublicAccount)]
#[derive(Clone, Debug)]
pub struct JsBip44PublicAccount {
    inner: Bip44PublicAccount<Secp256k1>,
}

#[wasm_bindgen(js_class = Bip44PublicAccount)]
impl JsBip44PublicAccount {
    /// Returns the underlying {@link Bip32PublicNode}.
    pub fn node(&self) -> JsBip32PublicNode {
        JsBip32PublicNode::from(self.inner.node().clone())
    }

    /// Accessor for the name of the underlying network.
    #[wasm_bindgen(getter)]
    pub fn network(&self) -> String {
        self.inner.network().subtree().name().to_owned()
    }

    /// Creates a sub-account for either external keys (receiving addresses) or internal keys (change addresses). This distinction is
    /// a common practice that might help in accounting.
    pub fn chain(&self, change: bool) -> Result<JsBip44PublicSubAccount, JsValue> {
        let account = self.inner.chain(Chain::from(change)).map_err_to_js()?;
        Ok(JsBip44PublicSubAccount::from(account))
    }

    /// Creates a key with a given index used on the chain for storing balance or
    /// authenticating actions. By default these keys are made on the receiving sub-account.
    pub fn key(&self, idx: i32) -> Result<JsBip44PublicKey, JsValue> {
        let sub_account = self.chain(false)?;
        sub_account.key(idx)
    }

    /// The coin identifier of the coin, defined in [SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md).
    #[wasm_bindgen(getter = slip44)]
    pub fn slip44(&self) -> i32 {
        self.inner.bip44_path().parent().slip44()
    }

    /// Accessor for the account index.
    #[wasm_bindgen(getter = account)]
    pub fn account(&self) -> i32 {
        self.inner.bip44_path().account()
    }

    /// Accessor for the BIP32 path of the account.
    #[wasm_bindgen(getter = path)]
    pub fn bip32_path(&self) -> String {
        self.inner.bip32_path().to_string()
    }

    // Secp specific methods...

    /// Recreates the public API of a BIP44 account from its parts
    #[wasm_bindgen(js_name = fromXpub)]
    pub fn from_xpub(
        account: i32, xpub: &str, network: &str,
    ) -> Result<JsBip44PublicAccount, JsValue> {
        let network = Networks::by_name(network).map_err_to_js()?;
        let inner = Bip44PublicAccount::from_xpub(account, xpub, network).map_err_to_js()?;
        Ok(JsBip44PublicAccount::from(inner))
    }

    /// Returns the extended public key in the BIP32 readable format with the version bytes of the network.
    #[wasm_bindgen(getter = xpub)]
    pub fn to_xpub(&self) -> String {
        self.inner.to_xpub()
    }
}

impl From<Bip44PublicAccount<Secp256k1>> for JsBip44PublicAccount {
    fn from(inner: Bip44PublicAccount<Secp256k1>) -> Self {
        Self { inner }
    }
}

impl Wraps<Bip44PublicAccount<Secp256k1>> for JsBip44PublicAccount {
    fn inner(&self) -> &Bip44PublicAccount<Secp256k1> {
        &self.inner
    }
}

/// Private API for a sub-account of a given account on a given coin that is either used for external keys (receiving addresses) or
/// internal keys (change addresses). Some implementations do not distinguish these and just always use receiving
/// addresses.
#[wasm_bindgen(js_name = Bip44SubAccount)]
#[derive(Clone, Debug)]
pub struct JsBip44SubAccount {
    inner: Bip44SubAccount<Secp256k1>,
}

#[wasm_bindgen(js_class = Bip44SubAccount)]
impl JsBip44SubAccount {
    /// Returns the underlying {@link Bip32Node}.
    pub fn node(&self) -> JsBip32Node {
        JsBip32Node::from(self.inner.node().clone())
    }

    /// Accessor for the name of the underlying network.
    #[wasm_bindgen(getter)]
    pub fn network(&self) -> String {
        self.inner.network().subtree().name().to_owned()
    }

    /// Creates a key with a given index used on the chain for storing balance or
    /// authenticating actions.
    pub fn key(&self, idx: i32) -> Result<JsBip44Key, JsValue> {
        let key = self.inner.key(idx).map_err_to_js()?;
        Ok(JsBip44Key::from(key))
    }

    /// The coin identifier of the coin, defined in [SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md).
    #[wasm_bindgen(getter = slip44)]
    pub fn slip44(&self) -> i32 {
        self.inner.bip44_path().parent().parent().slip44()
    }

    /// Accessor for the account index.
    #[wasm_bindgen(getter = account)]
    pub fn account(&self) -> i32 {
        self.inner.bip44_path().parent().account()
    }

    /// Accessor for whether the sub-account is for change addresses.
    #[wasm_bindgen(getter = change)]
    pub fn change(&self) -> bool {
        self.inner.bip44_path().chain().into()
    }

    /// Accessor for the BIP32 path of the sub-account.
    #[wasm_bindgen(getter = path)]
    pub fn bip32_path(&self) -> String {
        self.inner.bip32_path().to_string()
    }

    /// Neuters the sub-account and converts it into its public API
    pub fn neuter(&self) -> JsBip44PublicSubAccount {
        let inner = self.inner.neuter();
        JsBip44PublicSubAccount::from(inner)
    }

    // Secp specific methods...

    /// Recreates the private API of a BIP44 sub-account from its parts
    #[wasm_bindgen(js_name = fromXprv)]
    pub fn from_xprv(
        account: i32, change: bool, xprv: &str, network: &str,
    ) -> Result<JsBip44SubAccount, JsValue> {
        let network = Networks::by_name(network).map_err_to_js()?;
        let inner = Bip44SubAccount::from_xprv(account, Chain::from(change), xprv, network)
            .map_err_to_js()?;
        Ok(JsBip44SubAccount::from(inner))
    }

    /// Returns the extended private key in the BIP32 readable format with the version bytes of the network.
    #[wasm_bindgen(getter = xprv)]
    pub fn to_xprv(&self) -> String {
        self.inner.to_xprv()
    }
}

impl From<Bip44SubAccount<Secp256k1>> for JsBip44SubAccount {
    fn from(inner: Bip44SubAccount<Secp256k1>) -> Self {
        Self { inner }
    }
}

impl Wraps<Bip44SubAccount<Secp256k1>> for JsBip44SubAccount {
    fn inner(&self) -> &Bip44SubAccount<Secp256k1> {
        &self.inner
    }
}

/// Public API for a sub-account of a given account on a given coin that is either used for external keys (receiving addresses) or
/// internal keys (change addresses). Some implementations do not distinguish these and just always use receiving
/// addresses.
#[wasm_bindgen(js_name = Bip44PublicSubAccount)]
#[derive(Clone, Debug)]
pub struct JsBip44PublicSubAccount {
    inner: Bip44PublicSubAccount<Secp256k1>,
}

#[wasm_bindgen(js_class = Bip44PublicSubAccount)]
impl JsBip44PublicSubAccount {
    /// Returns the underlying {@link Bip32PublicNode}.
    pub fn node(&self) -> JsBip32PublicNode {
        JsBip32PublicNode::from(self.inner.node().clone())
    }

    /// Accessor for the name of the underlying network.
    #[wasm_bindgen(getter)]
    pub fn network(&self) -> String {
        self.inner.network().subtree().name().to_owned()
    }

    /// Creates a key with a given index used on the chain for storing balance or
    /// authenticating actions.
    pub fn key(&self, idx: i32) -> Result<JsBip44PublicKey, JsValue> {
        let key = self.inner.key(idx).map_err_to_js()?;
        Ok(JsBip44PublicKey::from(key))
    }

    /// The coin identifier of the coin, defined in [SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md).
    #[wasm_bindgen(getter = slip44)]
    pub fn slip44(&self) -> i32 {
        self.inner.bip44_path().parent().parent().slip44()
    }

    /// Accessor for the account index.
    #[wasm_bindgen(getter = account)]
    pub fn account(&self) -> i32 {
        self.inner.bip44_path().parent().account()
    }

    /// Accessor for whether the sub-account is for change addresses.
    #[wasm_bindgen(getter = change)]
    pub fn change(&self) -> bool {
        self.inner.bip44_path().chain().into()
    }

    /// Accessor for the BIP32 path of the sub-account.
    #[wasm_bindgen(getter = path)]
    pub fn bip32_path(&self) -> String {
        self.inner.bip32_path().to_string()
    }

    // Secp specific methods...

    /// Recreates the public API of a BIP44 sub-account from its parts
    #[wasm_bindgen(js_name = fromXpub)]
    pub fn from_xpub(
        account: i32, change: bool, xpub: &str, network: &str,
    ) -> Result<JsBip44PublicSubAccount, JsValue> {
        let network = Networks::by_name(network).map_err_to_js()?;
        let inner = Bip44PublicSubAccount::from_xpub(account, Chain::from(change), xpub, network)
            .map_err_to_js()?;
        Ok(JsBip44PublicSubAccount::from(inner))
    }

    /// Returns the extended public key in the BIP32 readable format with the version bytes of the network.
    #[wasm_bindgen(getter = xpub)]
    pub fn to_xpub(&self) -> String {
        self.inner.to_xpub()
    }
}

impl From<Bip44PublicSubAccount<Secp256k1>> for JsBip44PublicSubAccount {
    fn from(inner: Bip44PublicSubAccount<Secp256k1>) -> Self {
        Self { inner }
    }
}

impl Wraps<Bip44PublicSubAccount<Secp256k1>> for JsBip44PublicSubAccount {
    fn inner(&self) -> &Bip44PublicSubAccount<Secp256k1> {
        &self.inner
    }
}

/// Represents the private API of a key with a given index within a sub-account used on the chain for storing balance or
/// authenticating actions.
#[wasm_bindgen(js_name = Bip44Key)]
#[derive(Clone, Debug)]
pub struct JsBip44Key {
    inner: Bip44Key<Secp256k1>,
}

#[wasm_bindgen(js_class = Bip44Key)]
impl JsBip44Key {
    /// Returns the underlying {@link Bip32Node}.
    pub fn node(&self) -> JsBip32Node {
        JsBip32Node::from(self.inner.node().clone())
    }

    /// Accessor for the name of the underlying network.
    #[wasm_bindgen(getter)]
    pub fn network(&self) -> String {
        self.inner.network().subtree().name().to_owned()
    }

    /// Creates the private key for authenticating actions.
    #[wasm_bindgen(js_name = privateKey)]
    pub fn to_private_key(&self) -> JsSecpPrivateKey {
        self.node().to_private_key()
    }

    /// The coin identifier of the coin, defined in [SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md).
    #[wasm_bindgen(getter = slip44)]
    pub fn slip44(&self) -> i32 {
        self.inner.bip44_path().parent().parent().parent().slip44()
    }

    /// Accessor for the account index.
    #[wasm_bindgen(getter = account)]
    pub fn account(&self) -> i32 {
        self.inner.bip44_path().parent().parent().account()
    }

    /// Accessor for whether the sub-account is for change addresses.
    #[wasm_bindgen(getter = change)]
    pub fn change(&self) -> bool {
        self.inner.bip44_path().parent().chain().into()
    }

    /// Accessor for the key index within the sub-account.
    #[wasm_bindgen(getter = key)]
    pub fn key(&self) -> i32 {
        self.inner.bip44_path().key()
    }

    /// Accessor for the BIP32 path of the sub-account.
    #[wasm_bindgen(getter = path)]
    pub fn bip32_path(&self) -> String {
        self.inner.bip32_path().to_string()
    }

    /// Neuters the key and converts it into its public API
    pub fn neuter(&self) -> JsBip44PublicKey {
        let inner = self.inner.neuter();
        JsBip44PublicKey::from(inner)
    }

    // Secp specific methods...

    /// Returns the private key in the Wallet Import Format with the version byte of the network.
    ///
    /// @see SecpPrivateKey.toWif
    #[wasm_bindgen(getter = wif)]
    pub fn to_wif(&self) -> String {
        self.inner.node().to_wif(self.inner.network())
    }
}

impl From<Bip44Key<Secp256k1>> for JsBip44Key {
    fn from(inner: Bip44Key<Secp256k1>) -> Self {
        Self { inner }
    }
}

impl Wraps<Bip44Key<Secp256k1>> for JsBip44Key {
    fn inner(&self) -> &Bip44Key<Secp256k1> {
        &self.inner
    }
}

/// Represents a public key with a given index within a sub-account used on the chain for verifying signatures or validating
/// key identifiers.
#[wasm_bindgen(js_name = Bip44PublicKey)]
#[derive(Clone, Debug)]
pub struct JsBip44PublicKey {
    inner: Bip44PublicKey<Secp256k1>,
}

#[wasm_bindgen(js_class = Bip44PublicKey)]
impl JsBip44PublicKey {
    /// Returns the underlying {@link Bip32PublicNode}.
    pub fn node(&self) -> JsBip32PublicNode {
        JsBip32PublicNode::from(self.inner.node().clone())
    }

    /// Accessor for the name of the underlying network.
    #[wasm_bindgen(getter)]
    pub fn network(&self) -> String {
        self.inner.network().subtree().name().to_owned()
    }

    /// Creates the public key for verifying authentications done by this key.
    #[wasm_bindgen(js_name = publicKey)]
    pub fn to_public_key(&self) -> JsSecpPublicKey {
        self.node().to_public_key()
    }

    /// Creates the key identifier for the public key. This is an extra layer of security for single-use keys, so the
    /// revealing of the public key can be delayed to the point when the authenticated action (spending some coin or
    /// revoking access) makes the public key irrelevant after the action is successful.
    ///
    /// This method chooses the right algorithm used for creating key identifiers on the given network.
    #[wasm_bindgen(js_name = keyId)]
    pub fn to_key_id(&self) -> JsSecpKeyId {
        self.node().to_key_id()
    }

    /// The coin identifier of the coin, defined in [SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md).
    #[wasm_bindgen(getter = slip44)]
    pub fn slip44(&self) -> i32 {
        self.inner.bip44_path().parent().parent().parent().slip44()
    }

    /// Accessor for the account index.
    #[wasm_bindgen(getter = account)]
    pub fn account(&self) -> i32 {
        self.inner.bip44_path().parent().parent().account()
    }

    /// Accessor for whether the sub-account is for change addresses.
    #[wasm_bindgen(getter = change)]
    pub fn change(&self) -> bool {
        self.inner.bip44_path().parent().chain().into()
    }

    /// Accessor for the key index within the sub-account.
    #[wasm_bindgen(getter = key)]
    pub fn key(&self) -> i32 {
        self.inner.bip44_path().key()
    }

    /// Accessor for the BIP32 path of the sub-account.
    #[wasm_bindgen(getter = path)]
    pub fn bip32_path(&self) -> String {
        self.inner.bip32_path().to_string()
    }

    // Secp specific methods...

    /// Returns the P2PKH address that belongs key with the version byte of the network.
    #[wasm_bindgen(getter = address)]
    pub fn to_p2pkh_addr(&self) -> String {
        self.inner.to_p2pkh_addr()
    }
}

impl From<Bip44PublicKey<Secp256k1>> for JsBip44PublicKey {
    fn from(inner: Bip44PublicKey<Secp256k1>) -> Self {
        Self { inner }
    }
}

impl Wraps<Bip44PublicKey<Secp256k1>> for JsBip44PublicKey {
    fn inner(&self) -> &Bip44PublicKey<Secp256k1> {
        &self.inner
    }
}