Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1be92a6
Add DCR to supported assets and Decred to supported Chains
crux25 Apr 21, 2021
412f827
Add Decred docker conatiner
crux25 May 7, 2021
f41361d
Add Decred entry to docker-compose.yaml
crux25 May 7, 2021
ac20385
Add dcrd simnet rpc cert/key
crux25 May 18, 2021
14deb0a
Add dcrctl to decred docker toolchain
crux25 May 18, 2021
b8b9ac1
Implement decred client LatestBlock API
crux25 May 18, 2021
a170767
Add dcrwallet config
crux25 May 30, 2021
3090f5a
Docker Image: install screen
crux25 May 30, 2021
dd766ad
Add decred PK and Address to env
crux25 May 30, 2021
bfef60f
Impliment decred keygen
crux25 May 31, 2021
b77caf5
Add dcrwallet client
crux25 Jun 5, 2021
c6b0d3a
Impliment decred client UnspentOutputs
crux25 Jun 5, 2021
c7e6233
Fix typo
crux25 Jun 5, 2021
cd42609
Impliment decred client Output
crux25 Jun 5, 2021
f70fc06
Impliment decred client UnspentOutput
crux25 Jun 5, 2021
c111d6e
Impliment Decred BuildTx
crux25 Jun 9, 2021
e000d46
Impliment Decred utxo.Inputs and utxo.Outputs
crux25 Jun 9, 2021
baae53b
Impliment Decred utxo.sighashes
crux25 Jun 9, 2021
4a8d6e1
Impliment Decred utxo.sign
crux25 Jun 9, 2021
de1a6f9
Impliment Decred utxo.serialize
crux25 Jun 9, 2021
67e7694
impliment Decred utxo.hash
crux25 Jun 9, 2021
3431554
Impliment decred client SubmitTx
crux25 Jun 9, 2021
226abb5
Implement Decred client estimate fee
crux25 Jun 9, 2021
a52ebf8
Add Decred DEPRIV_KEY/ADDRESS Run Daemons in screen/ sinmet minning
crux25 Jun 9, 2021
af3eec3
Decred tests
crux25 Jun 9, 2021
b798b91
Modify dcrd port/add dcrwallet port
crux25 Jun 17, 2021
0c97d86
Docker image: expose dcrwallet port
crux25 Jun 17, 2021
a9c47b4
Modify Default DCRWalletHost/Error on failed NewClient/modify default…
crux25 Jun 17, 2021
34b0aac
Fetch tx confirmations/test tx confirmation.
crux25 Jun 18, 2021
8d484f4
Refactor decred estimatefee/estimatesmartfee API
crux25 Jun 21, 2021
5d5a8a3
Implement decred gas API/gas test
crux25 Jun 21, 2021
916e864
Implement Decred Address encoder/decoder
crux25 Jun 21, 2021
219695d
Add decred client interface
crux25 Jun 21, 2021
a81ba90
Import private key into dcrwallet for testing
crux25 Jun 21, 2021
b95b00b
Test credentials from .env
crux25 Jun 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions chain/decred/address.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package decred

import (
"fmt"

"github.com/decred/dcrd/chaincfg/v3"
"github.com/decred/dcrd/dcrutil/v3"
"github.com/decred/base58"
"github.com/renproject/multichain/api/address"
)

// AddressEncodeDecoder implements the address.EncodeDecoder interface
type AddressEncodeDecoder struct {
AddressEncoder
AddressDecoder
}

// NewAddressEncodeDecoder constructs a new AddressEncodeDecoder with the
// chain specific configurations
func NewAddressEncodeDecoder(params *chaincfg.Params) AddressEncodeDecoder {
return AddressEncodeDecoder{
AddressEncoder: NewAddressEncoder(params),
AddressDecoder: NewAddressDecoder(params),
}
}

// AddressEncoder encapsulates the chain specific configurations and implements
// the address.Encoder interface
type AddressEncoder struct {
params *chaincfg.Params
}

// NewAddressEncoder constructs a new AddressEncoder with the chain specific
// configurations
func NewAddressEncoder(params *chaincfg.Params) AddressEncoder {
return AddressEncoder{params: params}
}

// EncodeAddress implements the address.Encoder interface
func (encoder AddressEncoder) EncodeAddress(rawAddr address.RawAddress) (address.Address, error) {

// Validate that the base58 address is in fact in correct format.
encodedAddr := base58.Encode([]byte(rawAddr))
if _, err := dcrutil.DecodeAddress(encodedAddr, encoder.params); err != nil {
return address.Address(""), err
}

return address.Address(encodedAddr), nil
//return address.Address(""), nil
}



// AddressDecoder encapsulates the chain specific configurations and implements
// the address.Decoder interface
type AddressDecoder struct {
params *chaincfg.Params
}

// NewAddressDecoder constructs a new AddressDecoder with the chain specific
// configurations
func NewAddressDecoder(params *chaincfg.Params) AddressDecoder {
return AddressDecoder{params: params}
}

// DecodeAddress implements the address.Decoder interface
func (decoder AddressDecoder) DecodeAddress(addr address.Address) (address.RawAddress, error) {
decodedAddr, err := dcrutil.DecodeAddress(string(addr), decoder.params)
if err != nil {
return nil, fmt.Errorf("decode address: %v", err)
}

switch a := decodedAddr.(type) {
case *dcrutil.AddressPubKeyHash, *dcrutil.AddressScriptHash:
return address.RawAddress(base58.Decode(string(addr))), nil
default:
return nil, fmt.Errorf("non-exhaustive pattern: address %T", a)
}
}
Loading