(
rootPath: string = this.rootPath,
index: number = 0,
target = 0
)
| 54 | } |
| 55 | |
| 56 | createAccount( |
| 57 | rootPath: string = this.rootPath, |
| 58 | index: number = 0, |
| 59 | target = 0 |
| 60 | ): IWalletAccount { |
| 61 | const account = super.createAccount(rootPath, index, target); |
| 62 | const privateKeyBuffer = new PrivateKey(account.privateKey).toBuffer(); |
| 63 | const publicKeyBuffer = new PublicKey(account.publicKey).toBuffer(); |
| 64 | |
| 65 | const xOnlyPubkey = publicKeyBuffer.slice(1, 33); |
| 66 | |
| 67 | // Used for signing, since the output and address are using a tweaked key |
| 68 | // We must tweak the signer in the same way. |
| 69 | const privateKey = ECPair.fromPrivateKey(privateKeyBuffer); |
| 70 | const tweakedPrivateKey = privateKey.tweak( |
| 71 | bitcoin.crypto.taggedHash("TapTweak", xOnlyPubkey) |
| 72 | ); |
| 73 | |
| 74 | account.tweakedPrivateKey = tweakedPrivateKey.toWIF(); |
| 75 | account.xOnlyPubkey = xOnlyPubkey.toString("hex"); |
| 76 | |
| 77 | const network = |
| 78 | bitcoin.networks[ |
| 79 | this.config.network === "livenet" ? "bitcoin" : "testnet" |
| 80 | ]; |
| 81 | const addressP2WPKH = generateP2WPHKAddress( |
| 82 | Buffer.from(account.publicKey, "hex"), |
| 83 | network |
| 84 | ); |
| 85 | account.mainAddress = addressP2WPKH; |
| 86 | |
| 87 | const addressP2TRNote = generateP2TRNoteAddress( |
| 88 | Buffer.from(account.publicKey, "hex"), |
| 89 | network |
| 90 | ); |
| 91 | account.tokenAddress = addressP2TRNote; |
| 92 | |
| 93 | const addressP2TRNoteV1 = generateP2TRNoteAddressV1( |
| 94 | Buffer.from(account.publicKey, "hex"), |
| 95 | network |
| 96 | ); |
| 97 | account.addressP2TRNoteV1 = addressP2TRNoteV1; |
| 98 | |
| 99 | return account; |
| 100 | } |
| 101 | |
| 102 | async sendEstimate(toAddresses: ISendToAddress[], feePerKb?: number) { |
| 103 | const utxos = await this.fetchAllAccountUtxos(); |
no test coverage detected