Skip to content

Commit

Permalink
finish implementation
Browse files Browse the repository at this point in the history
Add support for new contracts through server/asset/eth and
client/asset/eth. Requires some modifications to client/core
and client/asset to add more swap info to some methods.

Differentiate wallet version from supported server versions.
  • Loading branch information
buck54321 committed Sep 5, 2022
1 parent 7a7241e commit 240ed63
Show file tree
Hide file tree
Showing 41 changed files with 647 additions and 744 deletions.
1 change: 1 addition & 0 deletions client/asset/bch/bch.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ var (
rpcWalletDefinition,
// electrumWalletDefinition, // getinfo RPC needs backport: https://github.com/Electron-Cash/Electron-Cash/pull/2399
},
ProtocolVersions: []uint32{0},
}
)

Expand Down
1 change: 1 addition & 0 deletions client/asset/btc/btc.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ var (
electrumWalletDefinition,
},
LegacyWalletIndex: 1,
ProtocolVersions: []uint32{0},
}
)

Expand Down
2 changes: 1 addition & 1 deletion client/asset/btc/electrum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestElectrumExchangeWallet(t *testing.T) {
}

// FindRedemption
redeemCoin, secretBytes, err := eew.FindRedemption(ctx, toCoinID(swapTxHash, swapVout), contract)
redeemCoin, secretBytes, err := eew.FindRedemption(ctx, toCoinID(swapTxHash, swapVout), contract, nil)
if err != nil {
t.Fatal(err)
}
Expand Down
1 change: 1 addition & 0 deletions client/asset/dcr/dcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ var (
ConfigOpts: append(rpcOpts, walletOpts...),
},
},
ProtocolVersions: []uint32{0},
}
swapFeeBumpKey = "swapfeebump"
splitKey = "swapsplit"
Expand Down
10 changes: 5 additions & 5 deletions client/asset/dcr/simnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func runTest(t *testing.T, splitTx bool) {
confContract := receipts[0].Contract()
checkConfs := func(n uint32, expSpent bool) {
t.Helper()
confs, spent, err := rig.beta().SwapConfirmations(tCtx, confCoin.ID(), confContract, tStart)
confs, spent, err := rig.beta().SwapConfirmations(tCtx, confCoin.ID(), confContract, tStart, nil)
if err != nil {
t.Fatalf("error getting %d confs: %v", n, err)
}
Expand Down Expand Up @@ -324,7 +324,7 @@ func runTest(t *testing.T, splitTx bool) {
if swapOutput.Value() != swapVal {
t.Fatalf("wrong contract value. wanted %d, got %d", swapVal, swapOutput.Value())
}
confs, spent, err := rig.alpha().SwapConfirmations(context.TODO(), swapOutput.ID(), receipt.Contract(), tStart)
confs, spent, err := rig.alpha().SwapConfirmations(context.TODO(), swapOutput.ID(), receipt.Contract(), tStart, nil)
if err != nil {
t.Fatalf("error getting confirmations: %v", err)
}
Expand Down Expand Up @@ -364,7 +364,7 @@ func runTest(t *testing.T, splitTx bool) {
waitNetwork()
ctx, cancel := context.WithDeadline(tCtx, time.Now().Add(time.Second*5))
defer cancel()
_, checkKey, err := rig.beta().FindRedemption(ctx, swapReceipt.Coin().ID(), nil)
_, checkKey, err := rig.beta().FindRedemption(ctx, swapReceipt.Coin().ID(), nil, nil)
if err != nil {
t.Fatalf("error finding unconfirmed redemption: %v", err)
}
Expand All @@ -384,7 +384,7 @@ func runTest(t *testing.T, splitTx bool) {
}
ctx, cancel2 := context.WithDeadline(tCtx, time.Now().Add(time.Second*5))
defer cancel2()
_, _, err = rig.beta().FindRedemption(ctx, swapReceipt.Coin().ID(), nil)
_, _, err = rig.beta().FindRedemption(ctx, swapReceipt.Coin().ID(), nil, nil)
if err != nil {
t.Fatalf("error finding confirmed redemption: %v", err)
}
Expand Down Expand Up @@ -420,7 +420,7 @@ func runTest(t *testing.T, splitTx bool) {
swapReceipt = receipts[0]

waitNetwork()
_, err = rig.beta().Refund(swapReceipt.Coin().ID(), swapReceipt.Contract(), tDCR.MaxFeeRate/4)
_, err = rig.beta().Refund(swapReceipt.Coin().ID(), swapReceipt.Contract(), nil, tDCR.MaxFeeRate/4)
if err != nil {
t.Fatalf("refund error: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions client/asset/doge/doge.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ var (
DefaultConfigPath: dexbtc.SystemConfigPath("dogecoin"),
ConfigOpts: configOpts,
}},
ProtocolVersions: []uint32{0},
}
)

Expand Down
Loading

0 comments on commit 240ed63

Please sign in to comment.