Skip to content
This repository was archived by the owner on Mar 23, 2021. It is now read-only.

Commit 257230b

Browse files
committed
taker sleeps before retrieving Bitcoin balance after swap
1 parent 0972096 commit 257230b

File tree

1 file changed

+7
-1
lines changed
  • new_project/examples/separate_apps/src

1 file changed

+7
-1
lines changed

new_project/examples/separate_apps/src/taker.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { MakerClient, Order, TakerNegotiator, TryParams } from "comit-sdk";
22
import { formatEther } from "ethers/utils";
33
import readLineSync from "readline-sync";
44
import { toBitcoin } from "satoshi-bitcoin-ts";
5-
import { createActor } from "./lib";
5+
import { createActor, sleep } from "./lib";
66

77
/**
88
* This executable function represents the taker side during a trade.
@@ -139,6 +139,12 @@ import { createActor } from "./lib";
139139

140140
console.log("Swapped!");
141141

142+
// The comit network daemon (cnd) processes new incoming blocks faster than bcoin.
143+
// This results in the final balance not being printed correctly, even though the redeem transaction was already
144+
// noticed by cnd.
145+
// In order to make sure the final balance is printed correctly we thus sleep for 1 second here.
146+
await sleep(1000);
147+
142148
// print balances after swapping
143149
console.log(
144150
"[Taker] Bitcoin balance: %f, Ether balance: %f",

0 commit comments

Comments
 (0)