@atomiqlabs/sdk 6.0.2 → 6.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -229,7 +229,7 @@ if(!result) {
|
|
|
229
229
|
await swap.refund();
|
|
230
230
|
} else {
|
|
231
231
|
//Swap successful, we can get the bitcoin txId
|
|
232
|
-
const bitcoinTxId = swap.
|
|
232
|
+
const bitcoinTxId = swap.getOutputTxId();
|
|
233
233
|
}
|
|
234
234
|
```
|
|
235
235
|
|
|
@@ -410,7 +410,27 @@ const marketPrice = swap.getPriceInfo().marketPrice; //Current market price
|
|
|
410
410
|
const difference = swap.getPriceInfo().difference; //Difference between the swap price & current market price
|
|
411
411
|
```
|
|
412
412
|
|
|
413
|
-
Initiating the swap
|
|
413
|
+
##### Initiating the swap
|
|
414
|
+
|
|
415
|
+
Using external wallet (e.g. browser-based like Xverse, Unisat, Phantom, etc.)
|
|
416
|
+
|
|
417
|
+
```typescript
|
|
418
|
+
//Obtain the funded PSBT (input already added) - ready for signing
|
|
419
|
+
const {psbt, signInputs} = await swap.getFundedPsbt({address: "", publicKey: ""});
|
|
420
|
+
const psbtBase64 = Buffer.from(psbt.toPSBT(0)).toString("base64"); //Base64 encoded PSBT
|
|
421
|
+
const psbtHex = Buffer.from(psbt.toPSBT(0)).toString("hex"); //hex encoded PSBT
|
|
422
|
+
//Pass `psbtBase64` or `psbtHex` (and also `signInputs`) to an external signer like Xverse, Unisat, etc.
|
|
423
|
+
const signedPsbtBase64 = await <signPsbt function of the external wallet>; //Call the signPsbt function of the external signer with psbtBase64 or psbtHex and signInputs
|
|
424
|
+
//NOTE: The signPsbt can also return hex-encoded PSBT
|
|
425
|
+
// const signedPsbtHex = await <signPsbt function of the external wallet>;
|
|
426
|
+
//Parse signed PSBT back to transaction object
|
|
427
|
+
const signedTransaction = Transaction.fromPSBT(Buffer.from(signedPsbtBase64, "base64")); //Import from @scure/btc-signer
|
|
428
|
+
//Or if the returned PSBT is hex-encoded
|
|
429
|
+
// const signedTransaction = Transaction.fromPSBT(Buffer.from(signedPsbtBase64, "hex")); //Import from @scure/btc-signer
|
|
430
|
+
const bitcoinTxId = await swap.submitPsbt(signedTransaction);
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
or sign inputs using a private key
|
|
414
434
|
|
|
415
435
|
```typescript
|
|
416
436
|
//Obtain the funded PSBT (input already added) - ready for signing
|