Skip to content
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

Merged
merged 3 commits into from Apr 30, 2024
Merged

multi: add pre-paid bonds #2730

merged 3 commits into from Apr 30, 2024

Conversation

buck54321
Copy link
Member

@buck54321 buck54321 commented Apr 5, 2024

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

@exitus1
Copy link

exitus1 commented Apr 5, 2024

If I'm reading this correctly, it's saying the bonds would be free?

@buck54321
Copy link
Member Author

If I'm reading this correctly, it's saying the bonds would be free?

Yes.

@JoeGruffins
Copy link
Member

JoeGruffins commented Apr 11, 2024

Unable to redeem if I come from the markets page "Create Account". I see the password field if I go from settings:
image

@JoeGruffins
Copy link
Member

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.

@buck54321
Copy link
Member Author

@JoeGruffins I squashed everything by accident, but I think I addressed your comments.

@JoeGruffins
Copy link
Member

Still seeing the problem:

stillnopass.mp4

@buck54321
Copy link
Member Author

Still seeing the problem:

stillnopass.mp4

Whoops. Should be fixed now.

@JoeGruffins
Copy link
Member

JoeGruffins commented Apr 15, 2024

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 $ curl -k -u :adminpass "https://127.0.0.1:16542/api/prepaybonds?days=10&n=10&strength=5"

I used one to make a new account, the server looks fine and says:

2024-04-15 12:50:41.451 [INF] AUTH: Creating new user account bc05c19c4f82ba9dec007dff529ad689ca91f29b981c69d3317310348f62e589 from pre-paid bond. addr = 127.0.0.1
2024-04-15 12:50:41.460 [INF] AUTH: Pre-paid bond accepted: acct bc05c19c4f82ba9dec007dff529ad689ca91f29b981c69d3317310348f62e589 from 127.0.0.1. Bonded tier 5, effective tier 5

But trying to trade I will see:

2024-04-15 03:53:52.679 [ERR] CORE: notify: |ERROR| (order) In-Flight Order Error - In-Flight order with ID 4 failed: new order request with DEX server 127.0.0.1:17273 market eth_btc failed: rpc error: error code 40: cannot use route 'limit' on an unauthorized connection - Order: 

Copy link
Contributor

@martonp martonp left a 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

Comment on lines +402 to +419
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)
}
Copy link
Contributor

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?

Copy link
Contributor

@ukane-philemon ukane-philemon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utAck.

Comment on lines +952 to +956
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)
}
}
Copy link
Contributor

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) }

Comment on lines +7095 to +7097
if bond.AssetID == account.PrepaidBondID {
c.insertPrepaidBond(dc, bond)
return bond.Strength, bond.AssetID
Copy link
Contributor

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)
Copy link
Contributor

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"

@buck54321 buck54321 merged commit 952f574 into decred:master Apr 30, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UX Suggestion: Reduce Fidelity Bond amount
5 participants