Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
Check to see if the bitcoin address is valid according to the chain
Browse files Browse the repository at this point in the history
  • Loading branch information
Beau Shinkle authored and nkuba committed Jun 11, 2021
1 parent b61944f commit 1629d74
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/chain/bitcoin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@ func (c Config) Validate() error {
if c.BeneficiaryAddress == "" {
return fmt.Errorf("a bitcoin address or extended public key (*pub) is required; configure one at [Extensions.TBTC.Bitcoin.BeneficiaryAddress]")
}
_, err := c.ChainParams()
chainParams, err := c.ChainParams()
if err != nil {
return fmt.Errorf("a valid chain name is required; choose between [mainnet, regtest, simnet, testnet3] and configure it at [Extensions.TBTC.Bitcoin.BitcoinChainName]: [%v]", err)
return fmt.Errorf("a valid chain name is required; choose between [mainnet, regtest, simnet, testnet3] and configure it at [Extensions.TBTC.Bitcoin.BitcoinChainName]: [%w]", err)
}
err = ValidateAddress(c.BeneficiaryAddress, chainParams)
if err != nil {
return fmt.Errorf(
"a valid bitcoin address or extended public key (*pub) is required; configure one at [Extensions.TBTC.Bitcoin.BeneficiaryAddress]: [%w]",
err,
)
}
return nil
}
Expand Down

0 comments on commit 1629d74

Please sign in to comment.