service-my-wallet-v3 Blockchain Wallet API Service

我要开发同款
匿名用户2021年12月24日
190阅读

技术信息

系统类型
Web3
授权协议
AGPL-3.0 License

作品详情

BlockchaiWalletAPIV2

ProgrammaticallyiterfacewithyourBlockchai.ifowallet.

CotetsGettigStartedUpgradigAPIDocumetatioRPCAPIIstallatioTroubleshootigUsageDevelopmetDeploymetGettigStarted

TousethisAPI,youwilleedtorusmalllocalservicewhichberesposibleformaagigyourBlockchai.ifowallet.YourapplicatioiteractswiththisservicelocallyviaHTTPAPIcalls.

Startbycompletigthefollowigsteps:

FollowtheistallatioistructiosStarttheserver:$blockchai-wallet-servicestart--port3000Referecethedocumetatioadstartiteractigwithyourwalletprogrammatically!

Notethatblockchai-wallet-serviceisdesigedtoberulocallyothesamemachieasyourapplicatioadthereforewillolyacceptcoectiosfromlocalhost.Ifyoumodifythisservicetoacceptexteralcoectios,besuretoaddtheappropriatefirewallrulestoprevetuauthorizeduse.

AAPIcodeisrequiredforwalletcreatioadhigherrequestlimits.Forbasicusage,oAPIcodeisrequired.RequestaAPIcodehere.

Upgradig

IfyoualreadyhaveaapplicatiothatusesBlockchai.ifo'sWalletAPI,youwilleedtocompletethestepsitheGettigStartedsectioaboveadthe,iyourapplicatiocode,replacecallstoblockchai.ifo/merchat/...withlocalhost:<port>/merchat/....

APIDocumetatio

Viewtheorigialdocumetatio.

AlledpoitspresetitheAPIdocumetatioabovearesupportediBlockchaiWalletAPIV2.Thedifferecesbetweetwoare:

The"cosolidateaddresses"edpoithasbeeomitted

AlledpoitscabecalledwithGETorPOST,adcaolybeaccessedfromlocalhost.

CreatigaewBlockchaiWallet

Edpoit:/api/v2/create

QueryParameters:

password-maiwalletpassword(required)api_code-blockchai.ifowalletapicode(required)priv-privatekeytoimportitowalletasfirstaddress(optioal)label-labeltogivetothefirstaddressgeeratedithewallet(optioal)email-emailtoassociatewiththeewlycreatedwallet(optioal)

SampleRespose:

{"guid":"05f290be-dbef-4636-a809-868893c51711","address":"13R9dBgKwBP29JKo11zhfi74YuBsMxJ4qY","label":"Maiaddress"}MakePaymet

Edpoit:/merchat/:guid/paymet

QueryParameters:

to-bitcoiaddresstosedto(required)amout-amoutisatoshitosed(required)password-maiwalletpassword(required)secod_password-secodwalletpassword(required,olyifsecodpasswordiseabled)api_code-blockchai.ifowalletapicode(optioal)from-bitcoiaddressoraccoutidextosedfrom(optioal)fee-specifytrasactiofeeisatoshifee_per_byte-specifytrasactiofee-per-byteisatoshi

Itisrecommededthattrasactiofeesarespecifiedusigthefee_per_byteparameter,whichwillcomputeyourfialfeebasedothesizeofthetrasactio.Youcaalsosetastaticfeeusigthefeeparameter,butdoigsomayresultialowfee-per-byte,leadigtologercofirmatiotimes.

SampleRespose:

{"to":["1A8JiWcwvpY7tAopUkSGuEYHmzGYfZPiq"],"from":["17p49XUC2fw4F53WjZqYAm4APKqhNPEkY"],"amouts":[200000],"fee":1000,"txid":"f322d01ad784e5deeb25464a5781c3b20971c1863679ca506e702e3e33c18e9c","success":true}SedtoMay

Edpoit:/merchat/:guid/sedmay

QueryParameters:

recipiets-aURIecodedJSONobject,withbitcoiaddressesaskeysadthesatoshiamoutsasvalues(required,seeexamplebelow)password-maiwalletpassword(required)secod_password-secodwalletpassword(required,olyifsecodpasswordiseabled)api_code-blockchai.ifowalletapicode(optioal)from-bitcoiaddressoraccoutidextosedfrom(optioal)fee-specifytrasactiofeeisatoshifee_per_byte-specifytrasactiofee-per-byteisatoshi

Itisrecommededthattrasactiofeesarespecifiedusigthefee_per_byteparameter,whichwillcomputeyourfialfeebasedothesizeofthetrasactio.Youcaalsosetastaticfeeusigthefeeparameter,butdoigsomayresultialowfee-per-byte,leadigtologercofirmatiotimes.

URIEcodigaJSONobjectiJavaScript:

varmyObject={address1:10000,address2:50000};varmyJSONStrig=JSON.strigify(myObject);//`ecodeURICompoet`isaglobalfuctiovarmyURIEcodedJSONStrig=ecodeURICompoet(myJSONStrig);//use`myURIEcodedJSONStrig`asthe`recipiets`parameter

SampleRespose:

{"to":["1A8JiWcwvpY7tAopUkSGuEYHmzGYfZPiq","18fyqiZzdTxdVo7g9ouRogB4uFj86JJiy"],"from":["17p49XUC2fw4F53WjZqYAm4APKqhNPEkY"],"amouts":[16000,5400030],"fee":2000,"txid":"f322d01ad784e5deeb25464a5781c3b20971c1863679ca506e702e3e33c18e9c","success":true}FetchWalletBalace

Edpoit:/merchat/:guid/balace

QueryParameters:

password-maiwalletpassword(required)api_code-blockchai.ifowalletapicode(required)

SampleRespose:

{"balace":10000}EableHDFuctioality

Edpoit:/merchat/:guid/eableHD

QueryParameters:

password-maiwalletpassword(required)api_code-blockchai.ifowalletapicode(optioal)

ThiswillupgradeawallettoaHD(HierarchicalDetermiistic)Wallet,whichallowstheuseofaccouts.SeeBIP32formoreiformatiooHDwalletsadaccouts.

ListActiveHDAccouts

Edpoit:/merchat/:guid/accouts

QueryParameters:

password-maiwalletpassword(required)api_code-blockchai.ifowalletapicode(optioal)ListHDxPubs

Edpoit:/merchat/:guid/accouts/xpubs

QueryParameters:

password-maiwalletpassword(required)api_code-blockchai.ifowalletapicode(optioal)CreateNewHDAccout

Edpoit:/merchat/:guid/accouts/create

QueryParameters:

label-labeltoassigtotheewlycreatedaccout(optioal)password-maiwalletpassword(required)api_code-blockchai.ifowalletapicode(optioal)GetSigleHDAccout

Edpoit:/merchat/:guid/accouts/:xpub_or_idex

QueryParameters:

password-maiwalletpassword(required)api_code-blockchai.ifowalletapicode(optioal)GetHDAccoutReceivigAddress

Edpoit:/merchat/:guid/accouts/:xpub_or_idex/receiveAddress

QueryParameters:

password-maiwalletpassword(required)api_code-blockchai.ifowalletapicode(optioal)CheckHDAccoutBalace

Edpoit:/merchat/:guid/accouts/:xpub_or_idex/balace

QueryParameters:

password-maiwalletpassword(required)api_code-blockchai.ifowalletapicode(optioal)ArchiveHDAccout

Edpoit:/merchat/:guid/accouts/:xpub_or_idex/archive

QueryParameters:

password-maiwalletpassword(required)api_code-blockchai.ifowalletapicode(optioal)UarchiveHDAccout

Edpoit:/merchat/:guid/accouts/:xpub_or_idex/uarchive

QueryParameters:

password-maiwalletpassword(required)api_code-blockchai.ifowalletapicode(optioal)ListAddresses(deprecated,usetheHDAPIistead)

Edpoit:/merchat/:guid/list

QueryParameters:

password-maiwalletpassword(required)api_code-blockchai.ifowalletapicode(optioal)

SampleRespose:

{"addresses":[{"balace":79434360,"address":"1A8JiWcwvpY7tAopUkSGuEYHmzGYfZPiq","label":"MyWallet","total_received":453300048335},{"balace":0,"address":"17p49XUC2fw4F53WjZqYAm4APKqhNPEkY","total_received":0}]}FetchAddressBalace(deprecated,usetheHDAPIistead)

Edpoit:/merchat/:guid/address_balace

QueryParameters:

address-addresstofetchbalacefor(required)password-maiwalletpassword(required)api_code-blockchai.ifowalletapicode(optioal)

Note:ulikethehostedAPI,thereisooptioofacofirmatiosparameterforspecifyigmiimumcofirmatios.

SampleRespose:

{"balace":129043,"address":"19r7jAbPDtfTKQ9VJpvDzFFxCjUJFKesVZ","total_received":53645423}GeerateAddress(deprecated,usetheHDAPIistead)

Edpoit:/merchat/:guid/ew_address

QueryParameters:

password-maiwalletpassword(required)label-labeltogivetotheaddress(optioal)api_code-blockchai.ifowalletapicode(optioal)

SampleRespose:

{"address":"18fyqiZzdTxdVo7g9ouRogB4uFj86JJiy","label":"MyNewAddress"}ArchiveAddress(deprecated,usetheHDAPIistead)

Edpoit:/merchat/:guid/archive_address

QueryParameters:

address-addresstoarchive(required)password-maiwalletpassword(required)api_code-blockchai.ifowalletapicode(optioal)

SampleRespose:

{"archived":"18fyqiZzdTxdVo7g9ouRogB4uFj86JJiy"}UarchiveAddress(deprecated,usetheHDAPIistead)

Edpoit:/merchat/:guid/uarchive_address

QueryParameters:

address-addresstouarchive(required)password-maiwalletpassword(required)api_code-blockchai.ifowalletapicode(optioal)

SampleRespose:

{"active":"18fyqiZzdTxdVo7g9ouRogB4uFj86JJiy"}RPC

BitcoidcompatibleRPCAPI.Fulldocumetatioavailablehere.

StartigtheRPCserver:

$blockchai-wallet-servicestart-rpc[optios]

ViewadditioaloptiosadistructiosuderUsage.

DifferecesfromserverAPI:

Optio-rpcsslisotsupportedMethodlistsiceblockisotsupportedParammiCofimatiosisotsupportedformethodslistreceivedbyaccoutadlistreceivedbyaddressParammiimumCofirmatiosisotsupportedformethodgetbalaceParamcofirmatiosisotsupportedformethodlistaccoutsResposesrepresetigtrasactioshaveadifferetformatIstallatio

odejsadpmarerequiredtoistalladusethisAPIservice.Istallatio:

$pmistall-gblockchai-wallet-service

Forthebeststabilityadperformace,makesureyouarealwaysusigthelatestversio.

Tocheckyourversio:

$blockchai-wallet-service-V

Toupdatetothelatestversio:

$pmupdate-gblockchai-wallet-service

Requires:

ode>=6.0.0pm>=3.0.0

Ifyouhaveissueswiththeistallatioprocess,seethetroubleshootigsectiobelow.

Troubleshootig

Istallatioerrors:

IfyouaregettigEACCESSorpermissios-relatederrors,itmightbeecessarytorutheistallasroot,usigthesudocommad.

Ifyouaregettigerrorscocerigode-gyporpytho,istallwithpmistall--o-optioal

Startuperrors:

Ifstartupfailswith/usr/bi/ev:ode:Nosuchfileordirectory,it'spossibleodeisotistalled,orwasistalledwithadifferetame(Ubutu,forexample,istallsodeasodejs).Ifodewasistalledwithadifferetame,createasymliktoyourodebiary:sudol-s/usr/bi/odejs/usr/bi/ode,oristallodethroughNodeVersioMaager.

Rutimeerrors:

IfyouareseeigaTypeErrorclaimigthataobjecthasomethod'compare',itisbecauseyouareoaversioofNodeoldertha0.12,beforethecomparemethodwasaddedtoBuffers.TryupgradigtoatleastNodeversio0.12.

Ifyouaregettigwalletdecryptioerrorsdespitehavigcorrectcredetials,theit'spossiblethatyoudoothaveJavaistalled,whichisrequiredbyadepedecyofthemy-wallet-v3module.NothavigJavaistalleddurigthepmistallprocesscaresultitheiabilitytodecryptwallets.DowloadtheJDKfromhereforMacorbyruigapt-getistalldefault-jdkodebia-basedliuxsystems.

TimeoutErrors:

Ifyouaregettigatimeoutrespose,additioalauthorizatiofromyourblockchaiwalletmayberequired.ThiscaoccurwheusigaurecogizedbrowserorIPaddress.AemailauthorizigtheAPIaccessattemptwillbesettotheregistereduserthatwillrequireactioiordertoauthorizefuturerequests.

Ifthissectiodidothelp,pleaseopeagithubissueorvisitoursupportceter.

Usage

Afteristalligtheservice,thecommadblockchai-wallet-servicewillbeavailableforuse.

Optios-h,--help-outputusageiformatio-V,--versio-outputtheversioumber-c,--cwd-usethecurretdirectoryasthewalletservicemodule(developmetoly)Commadsstart

Usage:blockchai-wallet-servicestart[optios]

Thiscommadwillstarttheservice,makigBlockchaiWalletAPIV2availableoaspecifiedport.

Commadoptios:

-h,--help-outputusageiformatio-p,--port-portumbertorutheservero(defaultsto3000)-b,--bid-bidtoaspecificip(defaultsto127.0.0.1,otethatbidigtoaipotherthathiscaleadtosecurityvulerabilities)--ssl-key-thepathtoyoursslkey(optioal)--ssl-cert-thepathtoyoursslcertificate(optioal)

Toopetheservicetoallicomigcoectios,bidto0.0.0.0.

start-rpc

Usage:blockchai-wallet-servicestart-rpc[optios]

ThiscommadwillstarttheJSONRPCserver.

Optios:

-k,--key-apicodetouseforserverrequests(requiredoptio)-p,--rpcport-rpcserverport(default:8000)-b,--bid-bidtoaspecificip(defaultsto127.0.0.1,otethatbidigtoaipotherthathiscaleadtosecurityvulerabilities)

GetaAPIcodehere.

Examples

TostarttheWalletAPIserviceoport3000:

$blockchai-wallet-servicestart--port3000DevelopmetCloethisrepoRuyar--igore-egiesRuyarstartDevserverisowruigoport3000

Ifyouaredevelopigblockchai-wallet-clietalogsidethismodule,itisusefultocreateasymliktomy-wallet-v3:

$l-s../path/to/my-wallet-v3ode_modules/blockchai-wallet-clietTestig$yartestCofiguratio

Optioalparameterscabecofiguredia.evfile:

PORT-portumberforruigdevserver(default:3000)BIND-ipaddresstobidtheserviceto(default:127.0.0.1)Deploymet

Ifyouwattouseblockchai-wallet-serviceiyourUNIXproductioserver,youjusthavetoru:

$ohupblockchai-wallet-servicestart--port3000&

功能介绍

Blockchain Wallet API V2 Programmatically interface with your Blockchain.info wallet. Contents Ge...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论