New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multi: add pre-paid bonds #2730
Conversation
If I'm reading this correctly, it's saying the bonds would be free? |
Yes. |
When I click on "Change Tier" in settings after inputting a paid bond, it takes me to the redeem paid bond screen but it should be one screen before that to choose asset and tier. |
fef9800
to
9a5b7c3
Compare
@JoeGruffins I squashed everything by accident, but I think I addressed your comments. |
Still seeing the problem: stillnopass.mp4 |
Whoops. Should be fixed now. |
The previous problem looks fine. But for some reason unable to trade. I made a simnet server with btc, dcr, and eth. I got some free bonds with I used one to make a new account, the server looks fine and says:
But trying to trade I will see:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing the same issue as @JoeGruffins
if newAcct { | ||
log.Infof("Creating new user account %s from pre-paid bond. addr = %s", acct.ID, conn.Addr()) | ||
err = auth.storage.CreateAccountWithBond(acct, dbBond) | ||
} else { | ||
log.Infof("Adding pre-bond for existing user account %v, addr = %s", acct.ID, conn.Addr()) | ||
err = auth.storage.AddBond(acct.ID, dbBond) | ||
} | ||
if err != nil { | ||
log.Errorf("Failure while storing pre-paid bond for acct %v (new = %v): %v", acct.ID, newAcct, err) | ||
return &msgjson.Error{ | ||
Code: msgjson.RPCInternalError, | ||
Message: "failed to store pre-paid bond", | ||
} | ||
} | ||
|
||
if err := auth.storage.DeletePrepaidBond(coinID); err != nil { | ||
log.Errorf("Error deleting pre-paid bond id = %s from database: %v", dex.Bytes(coinID), err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the transaction that adds the prepaid bond to an account also delete the bond?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utAck.
if acctExists { | ||
if dc.acct.locked() { // require authDEX first to reconcile any existing bond statuses | ||
return 0, newError(acctKeyErr, "acct locked %s (login first)", host) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove the nested if: if acctExists && dc.acct.locked() { return 0, newError(acctKeyErr, "acct locked %s (login first)", host) }
if bond.AssetID == account.PrepaidBondID { | ||
c.insertPrepaidBond(dc, bond) | ||
return bond.Strength, bond.AssetID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why we insert instead of checking db? I assume the redeemed prepaid bond was added to the db, no?
@@ -344,7 +352,7 @@ func (auth *AuthManager) storeBondAndRespond(conn comms.Link, bond *db.Bond, acc | |||
} | |||
err = conn.Send(resp) | |||
if err != nil { | |||
log.Warnf("Error sending postbond result to user %v: %v", acctID, err) | |||
log.Warnf("Error sending prepaid bond result to user %v: %v", acctID, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is also used for normal bonds, no? can just say "bond result"
fdefdec
to
523d749
Compare
This adds "pre-paid bonds", invite codes generated by the server that the client uses to generate a cost-free, time-limited fidelity bond.
Access the pre-paid bond dialog with the button at the bottom of the bond tier dialog.
Test on simnet with the
dextest/dcrdex/dexadm
script using./dexadm "prepaybonds?days=365&n=2&strength=2"
Closes #2728