MCPcopy Create free account
hub / github.com/NoteProtocol/NoteWallet / generateP2SHNoteAddress

Function generateP2SHNoteAddress

src/btc/btc-address.ts:53–78  ·  view source on GitHub ↗
(
  pubkey: Buffer,
  network: bitcoin.Network
)

Source from the content-addressed store, hash-verified

51
52// Pay to Witness Script Hash, where the redeem script is NOTE protocol script
53export function generateP2SHNoteAddress(
54 pubkey: Buffer,
55 network: bitcoin.Network
56): IAddressObject {
57 // Create redeem script
58 const redeemScript = bitcoin.script.fromASM(buildNoteScript(pubkey));
59
60 // Create P2WSH-NOTE address
61 const {output, address} = bitcoin.payments.p2sh({
62 redeem: {output: redeemScript, network},
63 network,
64 });
65
66 const script = output!.toString("hex");
67 // with SHA256 hash
68 const scriptHash = calcScriptHash(output!);
69
70 const type: AddressType = "P2SH-NOTE";
71
72 return {
73 address: address!,
74 script,
75 scriptHash,
76 type,
77 };
78}
79
80// Pay to Witness Public Key Hash address
81export function generateP2WPHKAddress(

Callers

nothing calls this directly

Calls 2

buildNoteScriptFunction · 0.90
calcScriptHashFunction · 0.90

Tested by

no test coverage detected