cli/wallet: switch claim command to claim NEP5 GAS

This commit is contained in:
Roman Khimov 2020-05-28 22:58:02 +03:00
parent 3b2644da4f
commit d496cc9687

View file

@ -247,46 +247,18 @@ func claimGas(ctx *cli.Context) error {
if err != nil { if err != nil {
return cli.NewExitError(err, 1) return cli.NewExitError(err, 1)
} }
info, err := c.GetClaimable(addrFlag.String()) // Temporary.
if err != nil { neoHash, err := util.Uint160DecodeStringLE("3b7d3711c6f0ccf9b1dca903d1bfa1d896f1238c")
return cli.NewExitError(err, 1)
} else if info.Unclaimed == 0 || len(info.Spents) == 0 {
fmt.Println("Nothing to claim")
return nil
}
var claim transaction.ClaimTX
for i := range info.Spents {
claim.Claims = append(claim.Claims, transaction.Input{
PrevHash: info.Spents[i].Tx,
PrevIndex: uint16(info.Spents[i].N),
})
}
tx := transaction.NewClaimTX(&claim)
validUntilBlock, err := c.CalculateValidUntilBlock()
if err != nil { if err != nil {
return cli.NewExitError(err, 1) return cli.NewExitError(err, 1)
} }
tx.ValidUntilBlock = validUntilBlock
tx.Sender = scriptHash
tx.AddOutput(&transaction.Output{ hash, err := c.TransferNEP5(acc, scriptHash, neoHash, 0, 0)
AssetID: core.UtilityTokenID(),
Amount: info.Unclaimed,
ScriptHash: scriptHash,
})
err = c.AddNetworkFee(tx, acc)
if err != nil { if err != nil {
return cli.NewExitError(err, 1) return cli.NewExitError(err, 1)
} }
_ = acc.SignTx(tx)
if err := c.SendRawTransaction(tx); err != nil {
return cli.NewExitError(err, 1)
}
fmt.Println(tx.Hash().StringLE()) fmt.Println(hash.StringLE())
return nil return nil
} }