原始文献 / 论坛帖 / Accounts example code

Accounts example code

Bitcointalk · 2010-12-10 19:21:03 UTC

AuthorSatoshi Nakamoto
TitleAccounts example code
Date2010-12-10 19:21:03 UTC
ForumBitcointalk · 原文

一些用 0.3.18 新的基于账户命令的示例伪代码。

print "send to " + getaccountaddress(username) + " to fund your account"
print "balance: " + getbalance(username, 0)
print "available balance: " + getbalance(username, 6)

// 如果你做了笔销售,把钱从他们的账户移到你的 "" 账户
if (move(username, "", amount, 6, "purchased item"))
SendTheGoods()

// 提现
sendfrom(username, bitcoinaddress, amount, 6, "withdrawal by user")

可以用 listtransactions(username) 给他们看最近交易列表。

英文原文

Some sample pseudocode using the new Accounts based commands in 0.3.18.

print "send to " + getaccountaddress(username) + " to fund your account"
print "balance: " + getbalance(username, 0)
print "available balance: " + getbalance(username, 6)

// if you make a sale, move the money from their account to your "" account
if (move(username, "", amount, 6, "purchased item"))
    SendTheGoods()

// withdrawal
sendfrom(username, bitcoinaddress, amount, 6, "withdrawal by user")

You can use listtransactions(username) to show them a list of their recent transactions.