Skip to content

Commit

Permalink
[models] Explicit declar type in signAndBroadcastTransactionAsync met…
Browse files Browse the repository at this point in the history
…hod for fix casting error
  • Loading branch information
mauricio1802 committed Dec 10, 2019
1 parent 4478b3d commit d4d90d5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
12 changes: 2 additions & 10 deletions src/models/walletsManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ func (walletM *WalletManager) sendFromOutputs(wltIds []string, from, addrTo, sky
var txn core.Transaction
var err error
if len(wltCache) > 1 {
fmt.Println("MULTI TXN")
walletsOutputs := make([]core.WalletOutput, 0)
for i, wlt := range wlts {
walletsOutputs = append(walletsOutputs, &util.SimpleWalletOutput{
Expand All @@ -413,7 +412,6 @@ func (walletM *WalletManager) sendFromOutputs(wltIds []string, from, addrTo, sky
}
txn, err = walletM.transactionAPI.Spend(walletsOutputs, outputsTo, &changeAddr, opt)
} else {
fmt.Println("SIMPLE TXN")
txn, err = wlts[0].Spend(outputsFrom, outputsTo, &changeAddr, opt)
}

Expand All @@ -430,7 +428,6 @@ func (walletM *WalletManager) sendFromOutputs(wltIds []string, from, addrTo, sky
return qTransaction
}
func (walletM *WalletManager) sendFromAddresses(wltIds []string, from, addrTo, skyTo, coinHoursTo []string, change string, automaticCoinHours bool, burnFactor string) *QTransaction {
fmt.Printf("WLTS %v\n", wltIds)
wltCache := make(map[string]core.Wallet, 0)
wlts := make([]core.Wallet, 0)
for _, wltId := range wltIds {
Expand Down Expand Up @@ -493,10 +490,8 @@ func (walletM *WalletManager) sendFromAddresses(wltIds []string, from, addrTo, s
UxOut: addrsFrom[i],
})
}
fmt.Println("MULTIPLE TRANSACTION")
txn, err = walletM.transactionAPI.SendFromAddress(walletsAddresses, outputsTo, changeAddr, opt)
} else {
fmt.Println("SINGLE TRANSACTION")
txn, err = wlts[0].SendFromAddress(addrsFrom, outputsTo, changeAddr, opt)
}

Expand Down Expand Up @@ -582,7 +577,6 @@ func (walletM *WalletManager) signTxn(wltIds, address []string, source string, t
logWalletManager.Error("Wallets and addresses provided are incorrect")
return nil
}

wltCache := make(map[string]core.Wallet)
wltByAddr := make(map[string]core.Wallet)
wlts := make([]core.Wallet, 0)
Expand Down Expand Up @@ -635,14 +629,14 @@ func (walletM *WalletManager) signTxn(wltIds, address []string, source string, t
logWalletManager.WithError(err).Warn("Error converting transaction")
return nil
}

return qTxn

}

func (walletM *WalletManager) signAndBroadcastTxnAsync(wltIds, addresses []string, source string, bridgeForPassword *QBridge, index []int, qTxn *QTransaction) {
channel := make(chan *QTransaction)
go func() {
pwd := func(message string, ctx core.KeyValueStore) (string, error) {
var pwd core.PasswordReader = func(message string, ctx core.KeyValueStore) (string, error) {
bridgeForPassword.BeginUse()
defer bridgeForPassword.EndUse()
bridgeForPassword.lock()
Expand Down Expand Up @@ -671,7 +665,6 @@ func (walletM *WalletManager) signAndBroadcastTxnAsync(wltIds, addresses []strin
if txn != nil {
walletM.broadcastTxn(txn)
}

}()
}

Expand All @@ -680,7 +673,6 @@ func (walletM *WalletManager) createEncryptedWallet(seed, label, wltType, passwo
pwd := util.ConstantPassword(password)
// NOTE: No easy way to get plain passwords in memory
password = ""
fmt.Println("WALLET TYPE ", wltType)
wlt, err := walletM.WalletEnv.GetWalletSet().CreateWallet(label, seed, wltType, true, pwd, scanN)
if err != nil {
logWalletManager.WithError(err).Error("Couldn't create encrypted wallet")
Expand Down
6 changes: 1 addition & 5 deletions src/ui/PageSend.qml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ Page {
var automaticCoinHours = stackView.currentItem.advancedPage.getAutomaticCoinHours()
var burnFactor = stackView.currentItem.advancedPage.getBurnFactor()
if (outs[0].length > 0){
console.log(outs)
txn = walletManager.sendFromOutputs(outs[1], outs[0], destinationSummary[0], destinationSummary[1], destinationSummary[2], changeAddress, automaticCoinHours, burnFactor)
} else {
if (addrs[0].length == 0){
Expand All @@ -66,7 +65,6 @@ Page {
addrs[1].push(walletSelected)
txn = walletManager.sendTo(walletSelected, stackView.currentItem.simplePage.getDestinationAddress(), stackView.currentItem.simplePage.getAmount())
}
console.log("HT "+txn.hoursTraspassed)
dialogSendTransaction.showPasswordField = false//isEncrypted// get if the current wallet is encrypted
//dialogSendTransaction.previewDate = "2019-02-26 15:27"
dialogSendTransaction.previewType = TransactionDetails.Type.Send
Expand Down Expand Up @@ -184,9 +182,7 @@ Page {
focus: true
onAccepted: {
walletManager.signAndBroadcastTxnAsync(walletsAddresses[1], walletsAddresses[0],"", bridgeForPassword, [], txn)
//var signedTxn = walletManager.signTxn(walletsAddresses[1], walletsAddresses[0],"", bridgeForPassword, [], txn)
//var injected = walletManager.broadcastTxn(signedTxn)
}
}
}

DialogGetPassword{
Expand Down
1 change: 0 additions & 1 deletion src/ui/SubPageSendAdvanced.qml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ Page {
walletManager.updateAddresses(comboBoxWalletsSendFrom.model.wallets[comboBoxWalletsSendFrom.checkedElements[i]].fileName)
var addresses = walletManager.getAddresses(comboBoxWalletsSendFrom.model.wallets[comboBoxWalletsSendFrom.checkedElements[i]].fileName)
for(var j = 0; j < addresses.length; j++) {
console.log(comboBoxWalletsSendFrom.model.wallets[comboBoxWalletsSendFrom.checkedElements[i]].fileName)
walletManager.updateOutputs(comboBoxWalletsSendFrom.model.wallets[comboBoxWalletsSendFrom.checkedElements[i]].fileName, addresses[j].address)
listOutputs.insertOutputs(walletManager.getOutputs(comboBoxWalletsSendFrom.model.wallets[comboBoxWalletsSendFrom.checkedElements[i]].fileName, addresses[j].address))
}
Expand Down

0 comments on commit d4d90d5

Please sign in to comment.