Skip to content

Commit

Permalink
add support for ZCash
Browse files Browse the repository at this point in the history
Implement block deserialization, tx deserialization/serialization
and input signing for ZCash and generalize those functions in the
client and server btc packages.

Implemenation notes
  1. zcashd does not support encrypted wallets. No passwords allowed.
  2. After starting the harness, it takes a few minutes for beta to
     get caught up.
  3. zcashd can take a very long time to get it's fee estimates primed.
  • Loading branch information
buck54321 committed May 19, 2022
1 parent 1c0ff51 commit e6d296f
Show file tree
Hide file tree
Showing 44 changed files with 2,954 additions and 170 deletions.
20 changes: 3 additions & 17 deletions client/asset/bch/bch.go
Expand Up @@ -170,28 +170,14 @@ func NewWallet(cfg *asset.WalletConfig, logger dex.Logger, network dex.Network)
// https://gist.github.com/markblundeberg/a3aba3c9d610e59c3c49199f697bc38b#making-unmalleable-smart-contracts
// https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki
NonSegwitSigner: rawTxInSigner,
// The old allowHighFees bool argument to sendrawtransaction.
ArglessChangeAddrRPC: true,
OmitAddressType: true,
// Bitcoin Cash uses estimatefee instead of estimatesmartfee, and even
// then, they modified it from the old Bitcoin Core estimatefee by
// removing the confirmation target argument.
FeeEstimator: estimateFee,
}

xcWallet, err := btc.BTCCloneWallet(cloneCFG)
if err != nil {
return nil, err
}

return &BCHWallet{
ExchangeWalletFullNode: xcWallet,
}, nil
}

// BCHWallet embeds btc.ExchangeWalletFullNode, but re-implements a couple of
// methods to perform on-the-fly address translation.
type BCHWallet struct {
*btc.ExchangeWalletFullNode
return btc.BTCCloneWallet(cloneCFG)
}

// rawTxSigner signs the transaction using Bitcoin Cash's custom signature
Expand Down Expand Up @@ -242,7 +228,7 @@ func translateTx(btcTx *wire.MsgTx) (*bchwire.MsgTx, error) {
return nil, err
}

bchTx := bchwire.NewMsgTx(bchwire.TxVersion)
bchTx := new(bchwire.MsgTx)
err = bchTx.Deserialize(bytes.NewBuffer(txB))
if err != nil {
return nil, err
Expand Down

0 comments on commit e6d296f

Please sign in to comment.