@@ -3,8 +3,8 @@ import { UTXOType, UTXO } from "silent-payments";
3
3
4
4
// Silent payment address generation using Diffie-Hellman
5
5
function generateSilentPaymentAddress (
6
- recipientPublicKey : bitcoin . ECPairInterface ,
7
- senderPrivateKey : bitcoin . ECPairInterface
6
+ recipientPublicKey : bitcoin . ECPair . ECPairInterface ,
7
+ senderPrivateKey : bitcoin . ECPair . ECPairInterface
8
8
) : string { // Changed return type from bitcoin.Address to string
9
9
try {
10
10
// Validate inputs
@@ -39,7 +39,6 @@ function generateSilentPaymentAddress(
39
39
throw new Error ( `Silent payment address generation failed: ${ error . message } ` ) ;
40
40
}
41
41
}
42
-
43
42
// Example usage of silent payment address generation
44
43
try {
45
44
const recipientKey = bitcoin . ECPair . makeRandom ( ) ; // For demo - replace with actual key
@@ -129,7 +128,7 @@ try {
129
128
const feeRate = 20 ; // Satoshis per byte
130
129
const sampleUTXOs : UTXO [ ] = [
131
130
// Replace with real UTXO data
132
- { txid : "1234..." , index : 0 , txout : { value : 100000 } }
131
+ { txid : "1234..." , vout : 0 , txout : { value : 100000 } }
133
132
] ;
134
133
const sampleOutputs : TransactionOutput [ ] = [
135
134
{ address : "bc1q..." , amount : 50000 }
@@ -142,7 +141,12 @@ try {
142
141
feeRate ,
143
142
changeAddress
144
143
) ;
145
- console . log ( "Transaction created successfully" ) ;
146
- } catch ( error ) {
147
- console . error ( error . message ) ;
144
+
145
+
146
+ console . log ( "Transaction created successfully:" , transactionWithFee ) ;
147
+ } catch ( error ) { if ( error instanceof Error ) {
148
+ console . error ( error . message ) ;
149
+ } else {
150
+ console . error ( "An unknown error occurred" ) ;
151
+ }
148
152
}
0 commit comments