"github.com/vapor/consensus"
"github.com/vapor/consensus/segwit"
"github.com/vapor/crypto/sha3pool"
- dbm "github.com/vapor/database/leveldb"
"github.com/vapor/protocol/bc"
"github.com/vapor/protocol/bc/types"
)
}
func (w *Wallet) getExternalDefinition(assetID *bc.AssetID) json.RawMessage {
- definitionByte := w.DB.Get(asset.ExtAssetKey(assetID))
+ definitionByte := w.store.GetAssetDefinition(assetID)
if definitionByte == nil {
return nil
}
}
// annotateTxs adds account data to transactions
-func annotateTxsAccount(txs []*query.AnnotatedTx, walletDB dbm.DB) {
+func annotateTxsAccount(txs []*query.AnnotatedTx, store WalletStorer) {
for i, tx := range txs {
for j, input := range tx.Inputs {
//issue asset tx input SpentOutputID is nil
if input.SpentOutputID == nil {
continue
}
- localAccount, err := getAccountFromACP(input.ControlProgram, walletDB)
+ localAccount, err := getAccountFromACP(input.ControlProgram, store)
if localAccount == nil || err != nil {
continue
}
txs[i].Inputs[j].AccountID = localAccount.ID
}
for j, output := range tx.Outputs {
- localAccount, err := getAccountFromACP(output.ControlProgram, walletDB)
+ localAccount, err := getAccountFromACP(output.ControlProgram, store)
if localAccount == nil || err != nil {
continue
}
}
}
-func getAccountFromACP(program []byte, walletDB dbm.DB) (*account.Account, error) {
+func getAccountFromACP(program []byte, store WalletStorer) (*account.Account, error) {
var hash common.Hash
accountCP := account.CtrlProgram{}
localAccount := account.Account{}
sha3pool.Sum256(hash[:], program)
-
- rawProgram := walletDB.Get(account.ContractKey(hash))
+ rawProgram := store.GetRawProgram(hash)
if rawProgram == nil {
return nil, fmt.Errorf("failed get account control program:%x ", hash)
}
return nil, err
}
- accountValue := walletDB.Get(account.Key(accountCP.AccountID))
+ accountValue := store.GetAccountByAccountID(accountCP.AccountID)
if accountValue == nil {
return nil, fmt.Errorf("failed get account:%s ", accountCP.AccountID)
}
in.InputID = id
e := tx.Entries[id]
switch e := e.(type) {
+ case *bc.VetoInput:
+ in.Type = "veto"
+ in.ControlProgram = orig.ControlProgram()
+ in.Address = w.getAddressFromControlProgram(in.ControlProgram, false)
+ in.SpentOutputID = e.SpentOutputId
+ arguments := orig.Arguments()
+ for _, arg := range arguments {
+ in.WitnessArguments = append(in.WitnessArguments, arg)
+ }
+
case *bc.CrossChainInput:
in.Type = "cross_chain_in"
in.ControlProgram = orig.ControlProgram()