func (cl *OpencxRPC) Withdraw(args WithdrawArgs, reply *WithdrawReply) (err error) {

	// e = h(asset)
	sha3 := sha3.New256()
	sha3.Write(args.Withdrawal.Serialize())
	e := sha3.Sum(nil)

	pubkey, _, err := koblitz.RecoverCompact(koblitz.S256(), args.Signature, e)
	if err != nil {
		err = fmt.Errorf("Error verifying order, invalid signature: \n%s", err)
		return
	}

	var coinType *coinparam.Params
	if coinType, err = util.GetParamFromName(args.Withdrawal.Asset.String()); err != nil {
		return
	}

	// We just ignore the address if they specify lightning.

	if args.Withdrawal.Lightning {

		if reply.Txid, err = cl.Server.WithdrawLightning(pubkey, args.Withdrawal.Amount, coinType); err != nil {
			err = fmt.Errorf("Error with withdraw command (withdraw from lightning): \n%s", err)
			return
		}

	} else {

		if reply.Txid, err = cl.Server.WithdrawCoins(args.Withdrawal.Address, pubkey, args.Withdrawal.Amount, coinType); err != nil {
			err = fmt.Errorf("Error with withdraw command (withdraw from chain): \n%s", err)
			return
		}

	}

	return
}
// Withdraw is the RPC Interface for Withdraw
Withdraw is the RPC Interface for Withdraw
// Withdraw is the RPC Interface for Withdraw
func (cl *OpencxRPC) Withdraw(args WithdrawArgs, reply *WithdrawReply) (err error) {
	sha3 := sha3.New256()
	sha3.Write(args.Withdrawal.Serialize())
	e := sha3.Sum(nil)
	pubkey, _, err := koblitz.RecoverCompact(koblitz.S256(), args.Signature, e)
	if err != nil {
		err = fmt.Errorf("Error verifying order, invalid signature: \n%s", err)
		return
	}
	var coinType *coinparam.Params
	if coinType, err = util.GetParamFromName(args.Withdrawal.Asset.String()); err != nil {
		return
	}
	if args.Withdrawal.Lightning {
		if reply.Txid, err = cl.Server.WithdrawLightning(pubkey, args.Withdrawal.Amount, coinType); err != nil {
			err = fmt.Errorf("Error with withdraw command (withdraw from lightning): \n%s", err)
			return
		}
	} else {
		if reply.Txid, err = cl.Server.WithdrawCoins(args.Withdrawal.Address, pubkey, args.Withdrawal.Amount, coinType); err != nil {
			err = fmt.Errorf("Error with withdraw command (withdraw from chain): \n%s", err)
			return
		}
	}
	return
}
func ( cl * OpencxRPC ) Withdraw ( args WithdrawArgs , reply * WithdrawReply ) ( err error ) { sha3 := sha3 . New256 ( ) sha3 . Write ( args . Withdrawal . Serialize ( ) ) e := sha3 . Sum ( nil ) pubkey , _ , err := koblitz . RecoverCompact ( koblitz . S256 ( ) , args . Signature , e ) if err != nil { err = fmt . Errorf ( " \n " , err ) return } var coinType * coinparam . Params if coinType , err = util . GetParamFromName ( args . Withdrawal . Asset . String ( ) ) ; err != nil { return } if args . Withdrawal . Lightning { if reply . Txid , err = cl . Server . WithdrawLightning ( pubkey , args . Withdrawal . Amount , coinType ) ; err != nil { err = fmt . Errorf ( " \n " , err ) return } } else { if reply . Txid , err = cl . Server . WithdrawCoins ( args . Withdrawal . Address , pubkey , args . Withdrawal . Amount , coinType ) ; err != nil { err = fmt . Errorf ( " \n " , err ) return } } return }
Withdraw is the RPC Interface for Withdraw
Withdraw is the RPC Interface for Withdraw
// e = h(asset) // We just ignore the address if they specify lightning.