Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
529 changes: 529 additions & 0 deletions client/asset/dcr/dcr.go

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions client/asset/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ const (
// too small to cover the gas fees when using a bundler.
ErrBundlerRedemptionLotSizeTooSmall = dex.ErrorKind("bundler redemption lot size too small")

// ErrMultisigPartialSend is returned when an error occurs after creating
// a multisig and sending some amount of funds.
ErrMultisigPartialSend = dex.ErrorKind("multisig partially sent")

// InternalNodeLoggerName is the name for a logger that is used to fine
// tune log levels for only loggers using this name.
InternalNodeLoggerName = "INTL"
Expand Down Expand Up @@ -816,6 +820,36 @@ type Bonder interface {
// required for efficient client bond management.
}

type PaymentMultisig struct {
NRequired, Locktime int64
AssetID uint32
SignerXpubs [][]byte
AddrToVal map[string]float64
SpendingTx *PaymentMultisigTx
}

type PaymentMultisigTx struct {
TxHex string `json:"txhex"`
HasSigs []bool `json:"hassigs"`
}

// Multisigner is a wallet capable of sending payments to multisig addresses.
type Multisigner interface {
Broadcaster
// SendFundsToMultisig sends amounts to a multisig address, then creates
// a transaction that spends those funds. ErrMultisigPartialSend and
// partial results are returned if an error happens after sending funds.
SendFundsToMultisig(ctx context.Context, pm *PaymentMultisig) (*PaymentMultisigTx, error)
// SignMultisig signs the pmTx with the supplied privateKey and inserts
// the signature at idx among the other signatures.
SignMultisig(ctx context.Context, pmTx *PaymentMultisigTx, privKey []byte) (*PaymentMultisigTx, error)
// RefundMultisig refunds a multisig if it is after the locktime and we
// are the sender.
RefundMultisig(ctx context.Context, pmTx *PaymentMultisigTx) (txHash string, err error)
// ViewPaymentMultisig returns a tx hex in human readable json format.
ViewPaymentMultisig(pmTx *PaymentMultisigTx) (string, error)
}

// Rescanner is a wallet implementation with rescan functionality.
type Rescanner interface {
// Rescan performs a rescan and block until it is done. If no birthday is
Expand Down
13 changes: 10 additions & 3 deletions client/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -1501,9 +1501,10 @@ type Core struct {
credMtx sync.RWMutex
credentials *db.PrimaryCredentials

loginMtx sync.Mutex
loggedIn bool
bondXPriv *hdkeychain.ExtendedKey // derived from creds.EncSeed on login
loginMtx sync.Mutex
loggedIn bool
bondXPriv *hdkeychain.ExtendedKey // derived from creds.EncSeed on login
multisigXPriv *hdkeychain.ExtendedKey // derived from creds.EncSeed on login

seedGenerationTime uint64

Expand Down Expand Up @@ -4581,6 +4582,10 @@ func (c *Core) Login(pw []byte) error {
if err != nil {
return false, fmt.Errorf("error deriving mesh private key: %w", err)
}
c.multisigXPriv, err = deriveMultisigXPriv(seed)
if err != nil {
return false, fmt.Errorf("error deriving multisig private key: %w", err)
}

if c.cfg.Mesh && c.net == dex.Simnet {
mesh, err := mesh.New(&mesh.Config{
Expand Down Expand Up @@ -4921,6 +4926,8 @@ func (c *Core) Logout() error {

c.bondXPriv.Zero()
c.bondXPriv = nil
c.multisigXPriv.Zero()
c.multisigXPriv = nil

c.loggedIn = false

Expand Down
12 changes: 12 additions & 0 deletions client/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,18 @@ func (tdb *TDB) Language() (string, error) {
return "en-US", nil
}

func (tdb *TDB) NextMultisigKeyIndex(assetID uint32) (uint32, error) {
return 0, nil
}

func (tdb *TDB) StoreMultisigIndexForPubkey(assetID, idx uint32, pubkey [33]byte) error {
return nil
}

func (tdb *TDB) MultisigIndexForPubkey(assetID uint32, pubkey [33]byte) (uint32, error) {
return 0, nil
}

type tCoin struct {
id []byte

Expand Down
Loading